Implement Homeworld mechanics through Caladan reinforcement checkpoint

Connect typed Homeworld custody, transport, battle, income, revival and Caladan reinforcement flows with private multiplayer recovery and controls. Preserve the optimized test workflow and keep unfinished rules modes gated. Verified with 3682 offline tests, typecheck, lint, production build and 40 HTTP tests; existing saved games remain unchanged.
This commit is contained in:
Quintine committed 2026-09-10 08:12:26 +10:00
1 parent 3be49512f7
commit 28ba1618ba
266 files changed
+47680 -16851

No files matched your search

+35 -11
View File
@@ -18,25 +18,42 @@ export function IxSubstitution({
if (g.decision?.kind !== 'ixSubstitution') return null;
const d = g.decision;
const me = g.players.find((p) => p.id === g.me)!;
const available = Object.entries(me.forces)
.filter(([key]) => splitLocation(key).territory === d.territory)
.map(
([key, count]) => [key, count - (me.elites?.forces[key] ?? 0)] as const,
)
.filter(([, count]) => count > 0);
const world = g.combatLocations?.find(
(place) => place.id === d.territory && place.kind === 'homeworld',
);
const available = (
world
? [[world.id, world.forces?.[me.id]?.normal ?? 0] as const]
: Object.entries(me.forces)
.filter(([key]) => splitLocation(key).territory === d.territory)
.map(
([key, count]) =>
[key, count - (me.elites?.forces[key] ?? 0)] as const,
)
).filter(([, count]) => count > 0);
const total = (value: Record<string, number>) =>
Object.values(value).reduce((a, b) => a + b, 0);
const invalid = (
selected: Record<string, number>,
limits: Record<string, number>,
) =>
Object.entries(selected).some(
([key, count]) =>
!Number.isSafeInteger(count) || count < 0 || count > (limits[key] ?? 0),
);
return (
<>
<p>
Exchange surviving suboids, one for one, to retain cyborgs lost in this
battle. Retained cyborgs return to their casualty sectors. Opponents may
cancel this substitution with Karama.
battle. Retained cyborgs return to{' '}
{world ? world.name : 'their casualty sectors'}. Opponents may cancel
this substitution with Karama.
</p>
<h3>Suboids to sacrifice</h3>
{available.map(([key, max]) => (
<label key={key}>
Sector {splitLocation(key).sector} · {max} suboids available
{world ? world.name : `Sector ${splitLocation(key).sector}`} · {max}{' '}
suboids available
<Input
type="number"
min={0}
@@ -51,7 +68,8 @@ export function IxSubstitution({
<h3>Cyborgs to retain</h3>
{Object.entries(d.losses).map(([key, max]) => (
<label key={key}>
Sector {splitLocation(key).sector} · {max} cyborgs lost
{world ? world.name : `Sector ${splitLocation(key).sector}`} · {max}{' '}
cyborgs lost
<Input
type="number"
min={0}
@@ -67,7 +85,13 @@ export function IxSubstitution({
{total(sources)} suboids for {total(recover)} cyborgs
</p>
<Button
disabled={busy || !total(sources) || total(sources) !== total(recover)}
disabled={
busy ||
!total(sources) ||
total(sources) !== total(recover) ||
invalid(sources, Object.fromEntries(available)) ||
invalid(recover, d.losses)
}
onClick={() => act({ type: 'decision', sources, recover })}
>
Confirm substitution