diff --git a/src/client/graphics/layers/WinModal.ts b/src/client/graphics/layers/WinModal.ts index 6f38b380a..7b421237b 100644 --- a/src/client/graphics/layers/WinModal.ts +++ b/src/client/graphics/layers/WinModal.ts @@ -215,7 +215,8 @@ export class WinModal extends LitElement implements Layer { !this.hasShownDeathModal && myPlayer && !myPlayer.isAlive() && - !this.game.inSpawnPhase() + !this.game.inSpawnPhase() && + myPlayer.hasSpawned() ) { this.hasShownDeathModal = true; this._title = "You died"; diff --git a/src/core/execution/SpawnExecution.ts b/src/core/execution/SpawnExecution.ts index 27b036eb1..695096c9f 100644 --- a/src/core/execution/SpawnExecution.ts +++ b/src/core/execution/SpawnExecution.ts @@ -25,26 +25,28 @@ export class SpawnExecution implements Execution { return; } + let player: Player = null; if (this.mg.hasPlayer(this.playerInfo.id)) { - const existing = this.mg.player(this.playerInfo.id); - existing.tiles().forEach((t) => existing.relinquish(t)); - getSpawnTiles(this.mg, this.tile).forEach((t) => { - existing.conquer(t); - }); - return; + player = this.mg.player(this.playerInfo.id); + } else { + player = this.mg.addPlayer( + this.playerInfo, + this.mg.config().startManpower(this.playerInfo), + ); } - const player = this.mg.addPlayer( - this.playerInfo, - this.mg.config().startManpower(this.playerInfo), - ); + player.tiles().forEach((t) => player.relinquish(t)); getSpawnTiles(this.mg, this.tile).forEach((t) => { player.conquer(t); }); - this.mg.addExecution(new PlayerExecution(player.id())); - if (player.type() == PlayerType.Bot) { - this.mg.addExecution(new BotExecution(player)); + + if (!player.hasSpawned()) { + this.mg.addExecution(new PlayerExecution(player.id())); + if (player.type() == PlayerType.Bot) { + this.mg.addExecution(new BotExecution(player)); + } } + player.setHasSpawned(true); } owner(): Player { diff --git a/src/core/game/Game.ts b/src/core/game/Game.ts index 1c316ed5b..002aeff18 100644 --- a/src/core/game/Game.ts +++ b/src/core/game/Game.ts @@ -316,6 +316,9 @@ export interface Player { largestClusterBoundingBox: { min: Cell; max: Cell } | null; lastTileChange(): Tick; + hasSpawned(): boolean; + setHasSpawned(hasSpawned: boolean): void; + // Territory tiles(): ReadonlySet; borderTiles(): ReadonlySet; diff --git a/src/core/game/GameUpdates.ts b/src/core/game/GameUpdates.ts index 5bb7c5693..044a2327e 100644 --- a/src/core/game/GameUpdates.ts +++ b/src/core/game/GameUpdates.ts @@ -111,6 +111,7 @@ export interface PlayerUpdate { incomingAttacks: AttackUpdate[]; outgoingAllianceRequests: PlayerID[]; stats: PlayerStats; + hasSpawned: boolean; } export interface AllianceRequestUpdate { diff --git a/src/core/game/GameView.ts b/src/core/game/GameView.ts index 430a24cb4..6bd58eb79 100644 --- a/src/core/game/GameView.ts +++ b/src/core/game/GameView.ts @@ -266,6 +266,9 @@ export class PlayerView { stats(): PlayerStats { return this.data.stats; } + hasSpawned(): boolean { + return this.data.hasSpawned; + } } export class GameView implements GameMap { diff --git a/src/core/game/PlayerImpl.ts b/src/core/game/PlayerImpl.ts index 7bdf19edc..e84f70d97 100644 --- a/src/core/game/PlayerImpl.ts +++ b/src/core/game/PlayerImpl.ts @@ -94,6 +94,8 @@ export class PlayerImpl implements Player { public _outgoingAttacks: Attack[] = []; public _outgoingLandAttacks: Attack[] = []; + private _hasSpawned = false; + constructor( private mg: GameImpl, private _smallID: number, @@ -162,6 +164,7 @@ export class PlayerImpl implements Player { ), outgoingAllianceRequests: outgoingAllianceRequests, stats: this.mg.stats().getPlayerStats(this.id()), + hasSpawned: this.hasSpawned(), }; } @@ -291,6 +294,14 @@ export class PlayerImpl implements Player { return this._tiles.size > 0; } + hasSpawned(): boolean { + return this._hasSpawned; + } + + setHasSpawned(hasSpawned: boolean): void { + this._hasSpawned = hasSpawned; + } + incomingAllianceRequests(): AllianceRequest[] { return this.mg.allianceRequests.filter((ar) => ar.recipient() == this); }