Connect bounded Diplomat retreat and record live deployment

This commit is contained in:
Quintine committed 2026-09-28 09:18:36 +10:00
1 parent 4801ce003b
commit c9a3625ff2
18 files changed
+601 -28

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
import { casualtyOptions, type CombatForces } from './combat';
export type RetreatForces = { normal: number; elite: number };
export type DiplomatRetreatSelection = RetreatForces & { destination: string | null };
export type DiplomatRetreatDestination = { location: string; choices: RetreatForces[] };
/** A retreat may take only counters not needed for any legal physical dial commitment. */
export function diplomatRetreatChoices(
forces: CombatForces,
dial: number,
support: number,
strength: number,
available: RetreatForces = forces,
): RetreatForces[] {
if (!Number.isSafeInteger(strength) || strength < 0) return [];
const choices: RetreatForces[] = [];
for (let normal = 0; normal <= Math.min(strength, forces.normal, available.normal); normal++)
for (let elite = 0; elite <= Math.min(strength - normal, forces.elite, available.elite); elite++) {
if (!normal && !elite) continue;
if (casualtyOptions({ ...forces, normal: forces.normal - normal, elite: forces.elite - elite }, dial, support).length)
choices.push({ normal, elite });
}
return choices;
}