fix multiplayer

This commit is contained in:
bijx
2026-06-15 23:49:39 -04:00
parent 3aabf16904
commit 65724a00c5
2 changed files with 20 additions and 0 deletions
+7
View File
@@ -184,6 +184,13 @@ export class GameServer {
if (gameConfig.waterNukes !== undefined) {
this.gameConfig.waterNukes = gameConfig.waterNukes ?? undefined;
}
if (gameConfig.invasionMode !== undefined) {
this.gameConfig.invasionMode = gameConfig.invasionMode;
}
if (gameConfig.invasionGracePeriod !== undefined) {
this.gameConfig.invasionGracePeriod =
gameConfig.invasionGracePeriod ?? undefined;
}
this.gameConfig.hostCheats = gameConfig.hostCheats;
}
+13
View File
@@ -85,4 +85,17 @@ describe("GameLifecycle", () => {
await expect(game.end()).resolves.toBeUndefined();
expect((game as any)._hasEnded).toBe(true);
});
it("propagates invasion mode settings through updateGameConfig", () => {
// Regression: the host's config update is an allowlist; invasion fields
// must be copied or private matches never start the invasion.
const game = new GameServer("test-game", mockLogger, Date.now(), {
gameType: GameType.Private,
} as any);
game.updateGameConfig({ invasionMode: true, invasionGracePeriod: 5 });
expect((game as any).gameConfig.invasionMode).toBe(true);
expect((game as any).gameConfig.invasionGracePeriod).toBe(5);
});
});