mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 09:50:43 +00:00
Keep static spawn timer for singleplayer games
PR #4198 made the spawn-phase timer count down numSpawnPhaseTurns(), but singleplayer never adds SpawnTimerExecution (GameRunner.ts), so its spawn phase doesn't end on a timer — it ends when the player spawns. The countdown would tick to 0 at ~10s while the phase kept going. In GameRightSidebar.tick(), restore the old static display (maxTimerValue * 60, or 0 when unset) during spawn phase for Singleplayer games, leaving the countdown for all other game types. Uses an explicit gameType check rather than _isSinglePlayer so replays of multiplayer games still count down.
This commit is contained in:
@@ -112,6 +112,16 @@ export class GameRightSidebar extends LitElement implements Controller {
|
||||
}
|
||||
|
||||
if (this.game.inSpawnPhase()) {
|
||||
// Singleplayer has no spawn timer (SpawnTimerExecution isn't added), so
|
||||
// the spawn phase doesn't count down — keep the old static display.
|
||||
if (this.game.config().gameConfig().gameType === GameType.Singleplayer) {
|
||||
const maxTimerValue = this.game.config().gameConfig().maxTimerValue;
|
||||
this.timer =
|
||||
maxTimerValue !== null && maxTimerValue !== undefined
|
||||
? maxTimerValue * 60
|
||||
: 0;
|
||||
return;
|
||||
}
|
||||
const spawnPhaseDurationTicks = this.game.config().numSpawnPhaseTurns();
|
||||
const currentTicks = this.game.ticks();
|
||||
const remainingTicks = spawnPhaseDurationTicks - currentTicks;
|
||||
|
||||
Reference in New Issue
Block a user