feat(#58): trade & embargoes — TurnResult.economy ops (trade/embargo, declare/lift) with a deterministic per-turn effect and war auto-suspension
CI / build + unit + e2e (pull_request) Successful in 2m3s

This commit is contained in:
2026-10-15 17:26:24 +00:00
parent ed91735c8a
commit b5ea8ba5a4
15 changed files with 776 additions and 23 deletions
+16
View File
@@ -33,6 +33,9 @@ function makeState(id: string): GameState {
},
// (v0.33.0, #56) no wars.
wars: [],
// (v0.35.0, #58) no active trades or embargoes.
trades: [],
embargoes: [],
};
}
@@ -149,6 +152,19 @@ describe('openDb', () => {
db.close();
});
it('(v0.35.0 #58) a legacy row saved before the trades/embargoes fields existed loads with them defaulted to []', () => {
const db = openDb(':memory:');
const legacy = makeState('legacy');
delete (legacy as { trades?: unknown[] }).trades; // a pre-v0.35 save (fields absent)
delete (legacy as { embargoes?: unknown[] }).embargoes;
db.save(legacy);
const loaded = db.load('legacy');
expect(loaded).not.toBeNull();
expect(loaded!.trades).toEqual([]);
expect(loaded!.embargoes).toEqual([]);
db.close();
});
it('delete removes a game by id and reports absence otherwise', () => {
const db = openDb(':memory:');
db.save(makeState('a'));