Random spawn. Avoid spawning near water. (#3009)

## Description:

Fixing
https://discord.com/channels/1359946986937258015/1360078040222142564/1463898386854973642

Now, if not all tiles on the spawn circle can be owned, the algorithm
tries to select another random spawn tile.

## 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:

nikolaj_mykola

---------

Co-authored-by: Ryan <7389646+ryanbarlow97@users.noreply.github.com>
This commit is contained in:
Mykola
2026-02-22 15:51:05 +00:00
committed by GitHub
co-authored by Ryan
parent 7c6c2b1fd8
commit 097c42740c
3 changed files with 60 additions and 19 deletions
+4 -4
View File
@@ -98,15 +98,15 @@ describe("Spawn execution", () => {
const game = await setup("half_land_half_ocean", undefined, [playerInfo]);
game.addExecution(new SpawnExecution("game_id", playerInfo, 50));
game.addExecution(new SpawnExecution("game_id", playerInfo, 60));
game.addExecution(new SpawnExecution("game_id", playerInfo, 10));
game.addExecution(new SpawnExecution("game_id", playerInfo, 20));
while (game.inSpawnPhase()) {
game.executeNextTick();
}
expect(game.playerByClientID("client_id")?.spawnTile()).toBe(60);
expect(game.playerByClientID("client_id")?.spawnTile()).toBe(20);
// Previous territory from first spawn should be relinquished
expect(game.owner(50).isPlayer()).toBe(false);
expect(game.owner(10).isPlayer()).toBe(false);
});
});