Restore safe Duke grants in early legacy games
Verify and publish checkpoint container / container (push) Successful in 10m31s
Verify and publish checkpoint container / container (push) Successful in 10m31s
This commit is contained in:
1 parent
59cb336c80
commit
22b463a395
10 files changed
+263
-11
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { acquireDuke } from '../game/duke-vidal';
|
||||
import { normalizeAutomaticGame } from '../game/engine';
|
||||
import { actHomeworldEcazDuke, createHomeworldEcazDukeFixture } from './fixture-homeworld-ecaz-duke';
|
||||
|
||||
const displacement = 'Occupied Ecaz displaced Duke Vidal’s ordinary faction grant';
|
||||
|
||||
for (const legacy of [false, true]) void test(
|
||||
`actual occupied Ecaz displacement clears ${legacy ? 'legacy' : 'uncertain'} Duke capture history`, () => {
|
||||
const f = createHomeworldEcazDukeFixture({ advanced: true, allied: true });
|
||||
// The public occupation and its recipient choice are earned by the native
|
||||
// fixture. Stage only the prior ordinary grant and uncertainty receipt at
|
||||
// the real battle boundary, then replay the fixture's actual battle plans.
|
||||
let game = structuredClone(f.worldResolution.before);
|
||||
game.dukeVidal = acquireDuke(game.dukeVidal!, f.ecaz, game.turn, 'ecaz');
|
||||
if (legacy) delete game.dukeCaptureUncertain;
|
||||
else game.dukeCaptureUncertain = true;
|
||||
const leader = structuredClone(game.dukeVidal.leader);
|
||||
for (const step of f.worldResolution.steps) game = actHomeworldEcazDuke(game, step.actor, step.action);
|
||||
assert.ok(game.log.some(entry => entry.text.includes(displacement)));
|
||||
assert.equal(game.dukeCaptureUncertain, false);
|
||||
assert.equal(game.dukeVidal?.controller, null);
|
||||
assert.equal(game.dukeVidal?.source, null);
|
||||
assert.deepEqual(game.dukeVidal?.leader, leader);
|
||||
assert.ok(f.ally);
|
||||
assert.equal(game.homeworldEcazDukeGrants?.length ?? 0, 0, 'the occupier still has a recipient choice');
|
||||
});
|
||||
|
||||
for (const legacy of [false, true]) void test(
|
||||
`without an ordinary Duke displacement ${legacy ? 'legacy' : 'uncertain'} capture history remains`, () => {
|
||||
const f = createHomeworldEcazDukeFixture({ advanced: true, allied: true });
|
||||
// This earned occupied position has no ordinary holder to displace and has
|
||||
// two recipients, so merely checking the opportunity must not clear it.
|
||||
const source = structuredClone(f.game);
|
||||
if (legacy) delete source.dukeCaptureUncertain;
|
||||
else source.dukeCaptureUncertain = true;
|
||||
const beforeLogs = source.log.filter(entry => entry.text.includes(displacement)).length;
|
||||
const done = normalizeAutomaticGame(source);
|
||||
assert.equal(done.dukeCaptureUncertain, legacy ? undefined : true);
|
||||
assert.equal(done.log.filter(entry => entry.text.includes(displacement)).length, beforeLogs);
|
||||
assert.deepEqual(done.dukeVidal, source.dukeVidal);
|
||||
});
|
||||
Reference in new issue
Block a user