Skip to content

Commit a1a382b

Browse files
committed
Fix nation immunity timing in singleplayer
1 parent b7e1ba3 commit a1a382b

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/core/game/GameImpl.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,17 @@ export class GameImpl implements Game {
793793
}
794794

795795
public isNationSpawnImmunityActive(): boolean {
796+
if (this.config().gameConfig().gameType === GameType.Singleplayer) {
797+
this.updateSingleplayerStartTick();
798+
if (this.inSpawnPhase()) {
799+
return true;
800+
}
801+
const startTick = this.singleplayerStartTick ?? this.ticks();
802+
return (
803+
startTick + this.config().nationSpawnImmunityDuration() > this.ticks()
804+
);
805+
}
806+
796807
return (
797808
this.config().numSpawnPhaseTurns() +
798809
this.config().nationSpawnImmunityDuration() >

src/core/game/GameView.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,17 @@ export class GameView implements GameMap {
859859
);
860860
}
861861
isNationSpawnImmunityActive(): boolean {
862+
if (this._config.gameConfig().gameType === GameType.Singleplayer) {
863+
this.updateSingleplayerStartTick();
864+
if (this.inSpawnPhase()) {
865+
return true;
866+
}
867+
const startTick = this.singleplayerStartTick ?? this.ticks();
868+
return (
869+
startTick + this._config.nationSpawnImmunityDuration() > this.ticks()
870+
);
871+
}
872+
862873
return (
863874
this._config.numSpawnPhaseTurns() +
864875
this._config.nationSpawnImmunityDuration() >

0 commit comments

Comments
 (0)