Connect Basic allied reserve shipment and provisional departure policy
This commit is contained in:
1 parent
fbbfabb404
commit
d3a09a95fe
9 files changed
+180
-6
No files matched your search
@@ -1,3 +1,53 @@
|
||||
import { MOBILE_STRONGHOLD, splitLocation } from './board';
|
||||
import { ecazOccupancyRelation } from './ecaz-occupy';
|
||||
import { presenceAt, type ForcePresence } from './force-presence';
|
||||
import type { OccupancySeat } from './occupancy';
|
||||
|
||||
/** Physical baseline distinguishes this turn's visitors from old co-occupation. */
|
||||
export type BasicAlliedShipment = Readonly<{
|
||||
player: string;
|
||||
ally: string;
|
||||
turn: number;
|
||||
territory: string;
|
||||
baseline: Readonly<{ normal: number; elite: number }>;
|
||||
}>;
|
||||
|
||||
/** Ordinary Basic reserve arrivals only; movement endpoints keep their guard. */
|
||||
export function isBasicAlliedShipmentVisit(
|
||||
context: Readonly<{
|
||||
advanced: boolean;
|
||||
phase: number;
|
||||
active: string | null;
|
||||
players: readonly OccupancySeat[];
|
||||
}>,
|
||||
player: OccupancySeat & Readonly<{ shipped?: boolean; moved?: number }>,
|
||||
to: string,
|
||||
): boolean {
|
||||
if (context.advanced || context.phase !== 5 || context.active !== player.id ||
|
||||
player.shipped !== false || player.moved !== 0 || to === 'polar_sink' ||
|
||||
to === MOBILE_STRONGHOLD) return false;
|
||||
const ally = context.players.find(seat => seat.id === player.ally);
|
||||
return !!ally && ally.ally === player.id && presenceAt(ally, to) > 0 &&
|
||||
ecazOccupancyRelation(context.players, player.id, ally.id, {
|
||||
kind: 'territory', id: to,
|
||||
}) !== 'ecazAlliance';
|
||||
}
|
||||
|
||||
export function alliedShipmentPhysicalPool(
|
||||
player: ForcePresence & { elites?: { forces: Readonly<Record<string, number>> } },
|
||||
to: string,
|
||||
): { normal: number; elite: number } {
|
||||
let normal = 0;
|
||||
let elite = 0;
|
||||
for (const key in player.forces) {
|
||||
if (splitLocation(key).territory !== to) continue;
|
||||
const special = player.elites?.forces[key] ?? 0;
|
||||
elite += special;
|
||||
normal += player.forces[key] - special;
|
||||
}
|
||||
return { normal, elite };
|
||||
}
|
||||
|
||||
export type AlliedSeparationQuoteContext = Readonly<{
|
||||
advanced: boolean;
|
||||
turn: number;
|
||||
|
||||
Reference in new issue
Block a user