Files
Dune/tests/fixture-battle-outcome-window.ts
Quintine 19e554666e Admit Mirror and Stone in Basic native E3 battles
Reuse original copied-weapon and typed coalition accounting for bare Basic
Ecaz/Moritani and selected Ix. Preserve optional-module guards and physical
card identity, actual force-owner commitments and native continuations.
2026-10-24 16:34:19 +11:00

22 lines
1020 B
TypeScript

import assert from 'node:assert/strict';
import { applyAction, viewGame, type Game } from '../game/engine';
/** Close only the actual final-priority controls. Do not bypass a response,
* pending native decision, Stone count, casualty choice or cleanup. */
export function finishBattleOutcomeWindow(source: Game): Game {
let game = source;
for (let count = 0; count < 2; count++) {
const window = game.battle?.outcomeWindow;
if (!window || window.closed) return game;
assert.ok(!game.response && !game.decision && !game.phaseOpening,
'Finish the actual native control before final battle priority');
const actor = [window.attacker, window.defender].find(id => !window.ready.includes(id));
assert.ok(actor);
const own = viewGame(game, actor).battle!.outcomeWindow;
assert.ok(own && !own.closed);
game = applyAction(game, actor, { type: 'battleOutcomeReady', event: own.event });
}
assert.ok(!game.battle?.outcomeWindow || game.battle.outcomeWindow.closed);
return game;
}