mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 21:24:14 +00:00
f1d162825e
Resolves #1041 ## Description: Remove the singleplayer spawn countdown so the game starts when the player spawns, spawn nations immediately after player spawn, and align game timer/max-timer timing with the new start point. Added a singleplayer regression test for spawn-immunity timing (GameImpl.test.ts) and updated spawn-phase loop tests to use gameType: GameType.Public where singleplayer behavior is not under test (e.g. MIRV/AI/Spawn/WinCheck-related suites), eliminating inSpawnPhase() timeout hangs after the new singleplayer start logic. https://github.com/user-attachments/assets/c07a585f-1153-490e-88ca-a91fc7ae5756 ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced ## Please put your Discord username so you can be contacted if a bug or regression is found: aotumuri
66 lines
2.0 KiB
TypeScript
66 lines
2.0 KiB
TypeScript
import { beforeEach, describe, expect, test } from "vitest";
|
|
import { PlayerExecution } from "../../../src/core/execution/PlayerExecution";
|
|
import {
|
|
Game,
|
|
Player,
|
|
PlayerInfo,
|
|
PlayerType,
|
|
} from "../../../src/core/game/Game";
|
|
import { setup } from "../../util/Setup";
|
|
import { executeTicks } from "../../util/utils";
|
|
|
|
let game: Game;
|
|
let largePlayer: Player;
|
|
let smallPlayer: Player;
|
|
|
|
describe("PlayerExecution Annexation Bug", () => {
|
|
beforeEach(async () => {
|
|
game = await setup(
|
|
"big_plains",
|
|
{ infiniteGold: true, instantBuild: true },
|
|
[
|
|
new PlayerInfo("large", PlayerType.Human, "client1", "large_id"),
|
|
new PlayerInfo("small", PlayerType.Human, "client2", "small_id"),
|
|
],
|
|
);
|
|
|
|
largePlayer = game.player("large_id");
|
|
smallPlayer = game.player("small_id");
|
|
|
|
game.addExecution(new PlayerExecution(largePlayer));
|
|
game.addExecution(new PlayerExecution(smallPlayer));
|
|
});
|
|
|
|
test("A large player is not reverse-annexed by surrounded smaller player", () => {
|
|
// Cluster A
|
|
smallPlayer.conquer(game.ref(50, 50));
|
|
smallPlayer.conquer(game.ref(50, 51));
|
|
smallPlayer.conquer(game.ref(51, 50));
|
|
smallPlayer.conquer(game.ref(51, 51));
|
|
// Cluster B
|
|
smallPlayer.conquer(game.ref(10, 10));
|
|
smallPlayer.conquer(game.ref(90, 90));
|
|
|
|
// Larger player gets the rest
|
|
game.map().forEachTile((tile) => {
|
|
if (game.ownerID(tile) !== smallPlayer.smallID()) {
|
|
largePlayer.conquer(tile);
|
|
}
|
|
});
|
|
|
|
const initialLargeTiles = largePlayer.numTilesOwned();
|
|
expect(largePlayer.numTilesOwned()).toBe(initialLargeTiles);
|
|
expect(smallPlayer.numTilesOwned()).toBeGreaterThan(0);
|
|
|
|
// Keep ticksPerClusterCalc and lastTileChange in mind
|
|
executeTicks(game, 20);
|
|
largePlayer.conquer(game.ref(49, 49));
|
|
smallPlayer.conquer(game.ref(50, 50));
|
|
|
|
// Annexation happens here
|
|
executeTicks(game, 50);
|
|
expect(largePlayer.numTilesOwned()).toBeGreaterThan(initialLargeTiles);
|
|
expect(smallPlayer.numTilesOwned()).toBe(0);
|
|
});
|
|
});
|