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,56 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
DUKE_CAPTURE_UNCERTAIN_BLOCK,
|
||||
dukeCaptureUncertaintyBlock,
|
||||
legacyDukeCaptureHistoryClear,
|
||||
type DukeCapturePolicyContext,
|
||||
} from '../game/ecaz-duke-capture-policy';
|
||||
|
||||
function earlyLegacy(): DukeCapturePolicyContext {
|
||||
return {
|
||||
advanced: true,
|
||||
players: [{ faction: 'ecaz' }, { faction: 'harkonnen' }],
|
||||
status: 'playing', turn: 1, phase: 0,
|
||||
battle: null, lastBattleContext: null, pendingCapture: null,
|
||||
response: null, decision: null,
|
||||
};
|
||||
}
|
||||
|
||||
void test('public first-turn phases before battle prove an unstamped legacy game safe', () => {
|
||||
for (let phase = 0; phase <= 5; phase++) {
|
||||
const game = { ...earlyLegacy(), phase };
|
||||
Object.defineProperty(game, 'dukeVidal', { get() { throw new Error('private custody read'); } });
|
||||
Object.defineProperty(game.players[1], 'capturedLeaders', { get() { throw new Error('private capture read'); } });
|
||||
assert.equal(legacyDukeCaptureHistoryClear(game), true);
|
||||
assert.equal(dukeCaptureUncertaintyBlock(game), null);
|
||||
}
|
||||
const unrelatedContinuation = { ...earlyLegacy(), response: { kind: 'nexus' }, decision: { kind: 'advisor' } };
|
||||
assert.equal(legacyDukeCaptureHistoryClear(unrelatedContinuation), true);
|
||||
});
|
||||
|
||||
void test('late, incomplete, or capture-continuation states cannot prove legacy safety', () => {
|
||||
const variants: Partial<DukeCapturePolicyContext>[] = [
|
||||
{ status: 'lobby' }, { status: undefined }, { turn: 2 }, { turn: undefined },
|
||||
{ phase: -1 }, { phase: 6 }, { phase: 0.5 }, { phase: undefined }, { phase: NaN },
|
||||
{ battle: {} }, { lastBattleContext: {} }, { pendingCapture: {} },
|
||||
{ response: { kind: 'capture' } }, { decision: { kind: 'captureOffer' } },
|
||||
{ decision: { kind: 'capturedLeader' } },
|
||||
];
|
||||
for (const variant of variants) {
|
||||
const game = { ...earlyLegacy(), ...variant };
|
||||
assert.equal(legacyDukeCaptureHistoryClear(game), false, JSON.stringify(variant));
|
||||
assert.equal(dukeCaptureUncertaintyBlock(game), DUKE_CAPTURE_UNCERTAIN_BLOCK, JSON.stringify(variant));
|
||||
}
|
||||
});
|
||||
|
||||
void test('explicit uncertainty is preserved and existing policy profiles are unchanged', () => {
|
||||
const uncertain = { ...earlyLegacy(), dukeCaptureUncertain: true };
|
||||
assert.equal(legacyDukeCaptureHistoryClear(uncertain), false);
|
||||
assert.equal(dukeCaptureUncertaintyBlock(uncertain), DUKE_CAPTURE_UNCERTAIN_BLOCK);
|
||||
const knownSafe = { ...earlyLegacy(), dukeCaptureUncertain: false, turn: 2 };
|
||||
assert.equal(legacyDukeCaptureHistoryClear(knownSafe), false);
|
||||
assert.equal(dukeCaptureUncertaintyBlock(knownSafe), null);
|
||||
assert.equal(dukeCaptureUncertaintyBlock({ ...uncertain, advanced: false }), null);
|
||||
assert.equal(dukeCaptureUncertaintyBlock({ ...uncertain, players: [{ faction: 'ecaz' }] }), null);
|
||||
});
|
||||
Reference in new issue
Block a user