Add a provisional post-reveal physical-count commitment for new outcome-changing Basic/Advanced Stone and copied Mirror battles. Keep all original sides sealed until complete and retain matching later typed losses. Preserve legacy, ordinary and invariant-winner timing. Carry the same constraint through card cleanup and native casualty consumers. Validation: frozen 16 files146/146, types/lint/build and14 original-action/rendered-control programmes; four minimal policies make both owned choices legally. Source timing is explicitly provisional. Wider combinations, assurance and deployed acceptance remain open. No saved-game, reset, restart or deployment operation.
26 lines
1.2 KiB
TypeScript
26 lines
1.2 KiB
TypeScript
import { casualtyOptions, type CombatForces } from './combat';
|
|
|
|
/** Printed physical commitments survive later card disposal and native aftercare. */
|
|
export type BattleCasualtyConstraint = {
|
|
fullyCommitted?: true;
|
|
physicalLossCount?: number;
|
|
};
|
|
|
|
export function casualtyConstraintFields(constraint: BattleCasualtyConstraint) {
|
|
return {
|
|
...(constraint.fullyCommitted ? {fullyCommitted:true as const} : {}),
|
|
...(constraint.physicalLossCount !== undefined ? {physicalLossCount:constraint.physicalLossCount} : {}),
|
|
};
|
|
}
|
|
|
|
export function committedCasualtyOptions(forces: CombatForces, dial: number, support: number,
|
|
constraint: BattleCasualtyConstraint = {}) {
|
|
const {fullyCommitted, physicalLossCount} = constraint;
|
|
if ((fullyCommitted !== undefined && fullyCommitted !== true) ||
|
|
(physicalLossCount !== undefined && (!Number.isSafeInteger(physicalLossCount) ||
|
|
physicalLossCount < 0 || physicalLossCount > forces.normal + forces.elite))) return [];
|
|
return casualtyOptions(forces, dial, support).filter(option =>
|
|
(!fullyCommitted || option.normal === forces.normal && option.elite === forces.elite) &&
|
|
(physicalLossCount === undefined || option.normal + option.elite === physicalLossCount));
|
|
}
|