Allow chosen Reinforcements reserve costs
Verify and publish checkpoint container / container (push) Successful in 11m11s

This commit is contained in:
Quintine committed 2026-10-29 04:41:26 +11:00
1 parent 9dd386ff7a
commit 1cf90f1328
16 files changed
+419 -44

No files matched your search

+17 -6
View File
@@ -17,15 +17,26 @@ export function isReinforcements(card: Card | undefined): boolean {
ecazTreacheryDefinition(card)?.card.effect === 'reinforcements';
}
/** Spend exactly three own reserve counters, ordinary before elite; never dial them. */
/** Legal elite counts for the three-counter fee, in ordinary-first order. */
export function reinforcementsEliteOptions(normalReserves: number, eliteReserves: number): number[] {
if (![normalReserves, eliteReserves].every(n => typeof n === 'number' && Number.isSafeInteger(n) && n >= 0))
throw new ReinforcementsError('Reinforcements needs valid nonnegative reserve counts.');
const minimum = Math.max(0, 3 - normalReserves);
const maximum = Math.min(3, eliteReserves);
return minimum > maximum ? [] : Array.from({ length: maximum - minimum + 1 }, (_, i) => minimum + i);
}
/** Spend exactly three own reserve counters; omitted choice retains the original ordinary-first rule. */
export function quoteReinforcements(
normalReserves: number,
eliteReserves: number,
selectedElite?: number,
): { normal: number; elite: number; bonus: 2 } {
if (![normalReserves, eliteReserves].every(n => typeof n === 'number' && Number.isSafeInteger(n) && n >= 0))
throw new ReinforcementsError('Reinforcements needs valid nonnegative reserve counts.');
if (normalReserves < 3 && eliteReserves < 3 - normalReserves)
const options = reinforcementsEliteOptions(normalReserves, eliteReserves);
if (!options.length)
throw new ReinforcementsError('Reinforcements needs at least three own forces in reserves.');
const normal = Math.min(3, normalReserves);
return { normal, elite: 3 - normal, bonus: 2 };
const elite = selectedElite === undefined ? options[0] : selectedElite;
if (!Number.isSafeInteger(elite) || !options.includes(elite))
throw new ReinforcementsError('Choose an available mix of three ordinary and elite reserve forces.');
return { normal: 3 - elite, elite, bonus: 2 };
}