mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-09 23:18:08 +00:00
feat: save stats to local storage
Victory lose, player stats, lobby config are stored to local storage (for later use)
This commit is contained in:
@@ -168,7 +168,6 @@ export class GameRunner {
|
||||
canBreakAlliance: player.isAlliedWith(other),
|
||||
canDonate: player.canDonate(other),
|
||||
canEmbargo: !player.hasEmbargoAgainst(other),
|
||||
stats: this.game.stats().getPlayerStats(other.id()),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -421,7 +421,6 @@ export interface PlayerInteraction {
|
||||
canTarget: boolean;
|
||||
canDonate: boolean;
|
||||
canEmbargo: boolean;
|
||||
stats: PlayerStats;
|
||||
}
|
||||
|
||||
export interface EmojiMessage {
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
UnitType,
|
||||
} from "./Game";
|
||||
import { TileRef, TileUpdate } from "./GameMap";
|
||||
import { PlayerStats } from "./Stats";
|
||||
|
||||
export interface GameUpdateViewData {
|
||||
tick: number;
|
||||
@@ -105,6 +106,7 @@ export interface PlayerUpdate {
|
||||
outgoingAttacks: AttackUpdate[];
|
||||
incomingAttacks: AttackUpdate[];
|
||||
outgoingAllianceRequests: PlayerID[];
|
||||
stats: PlayerStats;
|
||||
}
|
||||
|
||||
export interface AllianceRequestUpdate {
|
||||
|
||||
@@ -24,12 +24,13 @@ import {
|
||||
UnitInfo,
|
||||
UnitType,
|
||||
} from "./Game";
|
||||
import { ClientID } from "../Schemas";
|
||||
import { ClientID, GameID } from "../Schemas";
|
||||
import { TerraNulliusImpl } from "./TerraNulliusImpl";
|
||||
import { WorkerClient } from "../worker/WorkerClient";
|
||||
import { GameMap, GameMapImpl, TileRef, TileUpdate } from "./GameMap";
|
||||
import { GameUpdateViewData } from "./GameUpdates";
|
||||
import { DefenseGrid } from "./DefensePostGrid";
|
||||
import { PlayerStats } from "./Stats";
|
||||
|
||||
export class UnitView {
|
||||
public _wasUpdated = true;
|
||||
@@ -220,6 +221,9 @@ export class PlayerView {
|
||||
this.id(),
|
||||
);
|
||||
}
|
||||
stats(): PlayerStats {
|
||||
return this.data.stats;
|
||||
}
|
||||
}
|
||||
|
||||
export class GameView implements GameMap {
|
||||
@@ -240,6 +244,7 @@ export class GameView implements GameMap {
|
||||
private _config: Config,
|
||||
private _map: GameMap,
|
||||
private _myClientID: ClientID,
|
||||
private _gameID: GameID,
|
||||
) {
|
||||
this.lastUpdate = {
|
||||
tick: 0,
|
||||
@@ -487,4 +492,7 @@ export class GameView implements GameMap {
|
||||
numTilesWithFallout(): number {
|
||||
return this._map.numTilesWithFallout();
|
||||
}
|
||||
gameID(): GameID {
|
||||
return this._gameID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,6 +150,7 @@ export class PlayerImpl implements Player {
|
||||
}) as AttackUpdate,
|
||||
),
|
||||
outgoingAllianceRequests: outgoingAllianceRequests,
|
||||
stats: this.mg.stats().getPlayerStats(this.id()),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user