mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-10 19:14:36 +00:00
43d07ca85f
Tighten the package model around the determinism invariant: everything the
engine imports must itself be deterministic.
- Rename core-public -> engine-public (package, dir, `engine-public/*` alias,
all 118 import sites). It is the deterministic public surface the engine
depends on and that client/server also use.
- Move the pure formatting helpers (renderNumber/renderTroops) from shared
into engine-public/format — the engine uses them and they're deterministic.
- Drop the now-empty shared package (and its alias). `shared` was intended for
client/server-shared, engine-forbidden code; there is none yet, so it is
removed and can be re-added when such code appears.
Final graph: engine-public (leaf) <- engine <- {client, server};
client/server also -> engine-public.
Verified: tsc clean; 1364 + 65 tests pass; prod build succeeds; engine-public
is a leaf; engine has no client/server imports. Lockfile regenerated.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
27 lines
911 B
TypeScript
27 lines
911 B
TypeScript
import { SpawnExecution } from "engine/execution/SpawnExecution";
|
|
import { Player, PlayerInfo, PlayerType } from "engine/game/Game";
|
|
import { GameID } from "engine-public/Schemas";
|
|
import { setup } from "./util/Setup";
|
|
|
|
describe("Territory management", () => {
|
|
test("player owns the tile it spawns on", async () => {
|
|
const game = await setup("plains");
|
|
const gameID: GameID = "game_id";
|
|
game.addPlayer(
|
|
new PlayerInfo("test_player", PlayerType.Human, null, "test_id"),
|
|
);
|
|
const spawnTile = game.map().ref(50, 50);
|
|
game.addExecution(
|
|
new SpawnExecution(gameID, game.player("test_id").info(), spawnTile),
|
|
);
|
|
// Init the execution
|
|
game.executeNextTick();
|
|
// Execute the execution.
|
|
game.executeNextTick();
|
|
|
|
const owner = game.owner(spawnTile);
|
|
expect(owner.isPlayer()).toBe(true);
|
|
expect((owner as Player).name()).toBe("test_player");
|
|
});
|
|
});
|