Add pause button when replaying (#726)

## Description:

This PR does two things:

1. Allow pausing on replay
2. As part of the refactoring, in singleplayer games, LocalServer now
waits for the last turn to complete execution before sending the next
turn. Previously, low end devices would sometimes fall behind getting
the "playing the past" bug where commands were delayed. Now when a
devices cannot keep up, the entire game slows down.

## Please complete the following:

- [ ] I have added screenshots for all UI updates
- [ ] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced
- [ ] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:

<DISCORD USERNAME>

Co-authored-by: evan <openfrontio@gmail.com>
This commit is contained in:
evanpelle
2025-05-11 13:28:38 -07:00
committed by GitHub
parent d5ac65dea6
commit 0dc68ced31
9 changed files with 74 additions and 20 deletions
+1
View File
@@ -136,6 +136,7 @@ export interface Config {
defaultNukeSpeed(): number;
nukeDeathFactor(humans: number, tilesOwned: number): number;
structureMinDist(): number;
isReplay(): boolean;
}
export interface Theme {
+3 -2
View File
@@ -12,15 +12,16 @@ export let cachedSC: ServerConfig = null;
export async function getConfig(
gameConfig: GameConfig,
userSettings: UserSettings | null = null,
isReplay: boolean = false,
): Promise<Config> {
const sc = await getServerConfigFromClient();
switch (sc.env()) {
case GameEnv.Dev:
return new DevConfig(sc, gameConfig, userSettings);
return new DevConfig(sc, gameConfig, userSettings, isReplay);
case GameEnv.Preprod:
case GameEnv.Prod:
consolex.log("using prod config");
return new DefaultConfig(sc, gameConfig, userSettings);
return new DefaultConfig(sc, gameConfig, userSettings, isReplay);
default:
throw Error(`unsupported server configuration: ${process.env.GAME_ENV}`);
}
+4
View File
@@ -158,7 +158,11 @@ export class DefaultConfig implements Config {
private _serverConfig: ServerConfig,
private _gameConfig: GameConfig,
private _userSettings: UserSettings,
private _isReplay: boolean,
) {}
isReplay(): boolean {
return this._isReplay;
}
samHittingChance(): number {
return 0.8;
+7 -2
View File
@@ -41,8 +41,13 @@ export class DevServerConfig extends DefaultServerConfig {
}
export class DevConfig extends DefaultConfig {
constructor(sc: ServerConfig, gc: GameConfig, us: UserSettings) {
super(sc, gc, us);
constructor(
sc: ServerConfig,
gc: GameConfig,
us: UserSettings,
isReplay: boolean,
) {
super(sc, gc, us, isReplay);
}
// numSpawnPhaseTurns(): number {