Prove Emperor share and Moritani cleanup through native phases

This commit is contained in:
Quintine committed 2026-10-12 15:00:16 +11:00
1 parent 308797567e
commit adb054023d
10 files changed
+161 -91

No files matched your search

+43 -20
View File
@@ -3,7 +3,7 @@ import {
applyAction, createGame, initializeSemutaGameForAudit, joinGame, newPlayer,
viewGame, type Action, type Game, type Player,
} from '../game/engine';
import { baseDeck, spiceDeck } from '../game/cards';
import { nextRicheseSkillsTechNativeStep } from './fixture-richese-skills-tech';
import { SEMUTA_DRUG_ID } from '../game/semuta-drug';
export type SemutaEmperorShareKind = 'emperorGift' | 'emperorRevival';
@@ -45,32 +45,55 @@ export function moveSemutaEmperorCard(game: Game, id: string, to: string): strin
}
throw new Error(`Missing original physical ${id}`);
}
/** Genuine three-seat Richese/Emperor/Atreides Semuta setup; only the clock,
* phase, alliance, active seat and later held cards are conserved. */
/** Original native setup, first turn and actual worm alliance precede the share.
* Later hands/Tanks are staged by conserved moves; clocks, wallets and decks remain native. */
export function createSemutaEmperorShareFixture(kind: SemutaEmperorShareKind): SemutaEmperorShareFixture {
let game = createGame('SEMUTAEMPEROR', newPlayer('r', 'Richese', 'richese'), false, ['choam']);
joinGame(game, newPlayer('e', 'Emperor', 'emperor'));
joinGame(game, newPlayer('a', 'Atreides', 'atreides'));
for (const player of game.players) player.ready = true;
for (const player of game.players) game = applyAction(game, player.id, { type: 'ready' });
game = initializeSemutaGameForAudit(game);
game.status = 'playing';
game.phase = kind === 'emperorRevival' ? 4 : 2;
game.turn = 2;
game.storm = 18;
game.active = 'r';
game.order = ['r', 'e', 'a'];
game.ready = [];
game.decision = null;
game.response = null;
game.phaseOpening = null;
game.deck = baseDeck();
game.spiceDeck = spiceDeck();
const clean = () => !game.phaseOpening && !game.response && !game.decision;
const reach = (until: () => boolean) => {
for (let n = 0; !until() && n < 1800; n++) {
assert.notEqual(game.status, 'finished', 'Original native actions must reach the share');
const pending = game.pendingTreacheryDiscard;
const reaction = pending?.reaction;
const next = reaction?.stage === 'offer' && pending
? { actor: game.players.find(p => !reaction.passed.includes(p.id))!.id,
action: { type: 'semutaPass', event: pending.batch.event } }
: nextRicheseSkillsTechNativeStep(game);
game = applyAction(game, next.actor, next.action);
}
assert.ok(until(), 'Original native actions must reach the requested boundary');
};
const orderUnplayedSpice = (kinds: ('land' | 'worm')[]) => {
for (const [position, type] of kinds.entries()) {
const index = game.spiceDeck.findIndex((card, i) => i >= position &&
(type === 'land' ? 'territory' in card : 'worm' in card));
assert.ok(index >= position, 'An original unplayed Spice Card must remain');
game.spiceDeck.splice(position, 0, game.spiceDeck.splice(index, 1)[0]);
}
};
reach(() => game.status === 'playing');
orderUnplayedSpice(['land', 'land']);
reach(() => game.phase === 5 && clean());
for (const player of game.players) {
player.reserves += Object.values(player.forces).reduce((total, amount) => total + amount, 0);
player.forces = {};
}
reach(() => game.turn === 2 && game.phase === 1 && clean());
orderUnplayedSpice(['worm', 'land', 'land']);
reach(() => game.nexus && !game.spiceWindow && !game.spiceResolution && clean());
game = applyAction(game, 'e', { type: 'alliance', target: 'a' });
game = applyAction(game, 'a', { type: 'alliance', target: 'e' });
reach(() => game.phase === (kind === 'emperorRevival' ? 4 : 2) && clean());
const owner = semutaEmperorPlayer(game, 'e'), holder = semutaEmperorPlayer(game, 'r');
const recipient = semutaEmperorPlayer(game, 'a');
for (const player of game.players) { player.hand = []; player.spice = 20; player.forces = {}; }
owner.ally = recipient.id;
recipient.ally = owner.id;
recipient.tanks = 3;
for (const player of game.players) game.deck.push(...player.hand.splice(0));
assert.ok(recipient.reserves >= 3);
recipient.reserves -= 3;
recipient.tanks += 3;
const karamaId = moveSemutaEmperorCard(game, semutaEmperorCardId(game, card => card.effect === 'karama'), recipient.id);
const semuta = moveSemutaEmperorCard(game, SEMUTA_DRUG_ID, holder.id);
const karamaCard = recipient.hand.find(card => card.id === karamaId)!;