Resolve Duke uncertainty on public events
Verify and publish checkpoint container / container (push) Canceled after 0s

This commit is contained in:
Quintine committed 2026-10-29 19:30:00 +11:00
1 parent 57e7611468
commit 59cb336c80
14 files changed
+360 -25

No files matched your search

@@ -0,0 +1,54 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { applyAction, type Game } from '../game/engine';
import { DUKE_VIDAL_ID, dukeController } from '../game/duke-vidal';
import { createNexusDukeDeathFixture } from './fixture-nexus-duke-capture';
import { cancelMoritaniDukeReclaim, createMoritaniDukeCaptureFixture,
reclaimMoritaniDuke } from './fixture-moritani-duke-capture';
/** Both marker states occur after a publicly possible Duke capture: true on
* fresh games, absent on older saves whose complete history is unavailable. */
function marker(game: Game, value: 'uncertain' | 'legacy') {
if (value === 'uncertain') game.dukeCaptureUncertain = true;
else delete game.dukeCaptureUncertain;
}
for (const state of ['uncertain', 'legacy'] as const) {
void test(`public Ecaz Cunning resolves ${state} Duke uncertainty`, () => {
// Native setup, an actual battle death, and the original Nexus draw.
const fixture = createNexusDukeDeathFixture(), game = fixture.window;
marker(game, state);
const done = applyAction(game, fixture.owner, fixture.action);
assert.equal(done.dukeCaptureUncertain, false);
assert.equal(done.dukeVidal?.leader.id, DUKE_VIDAL_ID);
assert.equal(dukeController(done.dukeVidal!), fixture.owner);
assert.equal(done.dukeVidal?.source, 'ecazNexus');
assert.ok(done.log.some(entry => entry.text.includes('spent Ecaz Nexus Cunning to take Duke')));
});
for (const execute of [false, true]) {
void test(`public Moritani ${execute ? 'Tanks outcome' : 'acquisition'} resolves ${state} Duke uncertainty`, () => {
// Native setup, actual capture and actual Moritani response. The
// original physical lottery entropy is controlled by the shared fixture.
const f = createMoritaniDukeCaptureFixture({ execute });
marker(f.game, state);
const { after } = reclaimMoritaniDuke(f);
assert.equal(after.dukeCaptureUncertain, false);
assert.equal(after.dukeVidal?.leader.id, DUKE_VIDAL_ID);
assert.equal(after.dukeVidal?.leader.dead, execute);
assert.equal(dukeController(after.dukeVidal!), execute ? null : f.owner);
assert.ok(after.log.some(entry => execute
? entry.text.includes('Duke acquisition resolved with the shared disc in the Tanks')
: entry.text.includes('acquired Duke Vidal for one battle')));
});
}
void test(`canceled Moritani acquisition preserves ${state} Duke uncertainty`, () => {
const f = createMoritaniDukeCaptureFixture({ karama: true });
marker(f.game, state);
const { after } = cancelMoritaniDukeReclaim(f);
assert.equal(after.dukeCaptureUncertain, state === 'uncertain' ? true : undefined);
assert.equal(dukeController(after.dukeVidal!), f.captor);
assert.ok(after.log.some(entry => entry.text.includes('Karama prevented Moritani from acquiring Duke')));
});
}