From f76c8dfb9388ee4053d7aff5af7341d2aa2b76d7 Mon Sep 17 00:00:00 2001 From: Quintine <15965533+Quintine@users.noreply.github.com> Date: Mon, 26 Oct 2026 23:11:48 +1100 Subject: [PATCH] Combine current battle decisions with turn commitments --- components/game-table.tsx | 49 ++-- components/truthtrance.tsx | 4 +- components/turn-action-fields.tsx | 67 ++++- components/turn-action-promises.tsx | 39 ++- docs/CURRENT_STATUS.md | 34 +++ docs/IMPLEMENTATION_STATUS.md | 36 +++ docs/TRUTHTRANCE_TURN_ACTIONS.md | 62 ++++- game/engine.ts | 173 +++++++++++- game/reference.ts | 12 +- game/truthtrance.ts | 20 ++ game/turn-action-promises.ts | 182 ++++++++++++- tests/fixture-truth-turn-combat.ts | 168 ++++++++++++ tests/truth-turn-action-controls.test.tsx | 107 +++++++- tests/truth-turn-combat-runtime.test.ts | 304 ++++++++++++++++++++++ tests/turn-action-promises.test.ts | 189 ++++++++++++++ 15 files changed, 1380 insertions(+), 66 deletions(-) create mode 100644 tests/fixture-truth-turn-combat.ts create mode 100644 tests/truth-turn-combat-runtime.test.ts diff --git a/components/game-table.tsx b/components/game-table.tsx index ac386e5a..9ee09221 100644 --- a/components/game-table.tsx +++ b/components/game-table.tsx @@ -261,7 +261,7 @@ import { territory, splitLocation, } from '@/game/board'; -import type { Action, GameView } from '@/game/engine'; +import type { Action, GameView, Plan } from '@/game/engine'; import { PLAYER_CIRCLE_SECTORS } from '@/game/player-positions'; import { SeatAutopilot } from './seat-autopilot'; import { @@ -570,6 +570,26 @@ export function GameTable({ }); const [aidAmount, setAidAmount] = useState(0); const [allyPayment, setAllyPayment] = useState(''); + const fillBattlePlan = (plan: Plan) => { + setDial(plan.dial); + setSupport(plan.support); + setBankerSpice(plan.bankerSpice ?? 0); + setAllyPayment(plan.allyPayment === undefined ? '' : String(plan.allyPayment)); + setLeader(plan.leader ?? ''); + setWeapon(plan.weapon ?? ''); + setDefense(plan.defense ?? ''); + setPlanetologistDraft({ + key: `${g.battle?.event ?? ''}:${plan.leader ?? ''}:${plan.weapon ?? ''}`, + enabled: plan.planetologistSpecial === true, + }); + setKwisatz(!!plan.kwisatz); + if (plan.reinforcementsSources) { + const chosen = JSON.stringify(plan.reinforcementsSources); + const index = reinforcementsSourceChoices?.findIndex(choice => JSON.stringify(choice) === chosen); + if (index !== undefined && index >= 0) + setReinforcementsSourceDraft({ key: reinforcementsSourceKey, index }); + } + }; const [combineSectors, setCombineSectors] = useState(false); const [moveNoField, setMoveNoField] = useState(false); const [moveForces, setMoveForces] = useState>({}); @@ -2067,7 +2087,7 @@ export function GameTable({ {g.status === 'playing' && } {g.status === 'playing' && } {g.status === 'playing' && } - {g.status === 'playing' && } + {g.status === 'playing' && } {g.guildBetrayalReaction ? ( ) : g.richeseBetrayalReaction ? ( @@ -5311,30 +5331,7 @@ export function GameTable({ act={act} game={g} busy={busy} - fill={(plan) => { - setDial(plan.dial); - setSupport(plan.support); - setBankerSpice(plan.bankerSpice ?? 0); - setAllyPayment( - plan.allyPayment === undefined - ? '' - : String(plan.allyPayment), - ); - setLeader(plan.leader ?? ''); - setWeapon(plan.weapon ?? ''); - setDefense(plan.defense ?? ''); - setPlanetologistDraft({ - key: `${g.battle?.event ?? ''}:${plan.leader ?? ''}:${plan.weapon ?? ''}`, - enabled: plan.planetologistSpecial === true, - }); - setKwisatz(!!plan.kwisatz); - if (plan.reinforcementsSources) { - const chosen = JSON.stringify(plan.reinforcementsSources); - const index = reinforcementsSourceChoices?.findIndex(choice => JSON.stringify(choice) === chosen); - if (index !== undefined && index >= 0) - setReinforcementsSourceDraft({ key: reinforcementsSourceKey, index }); - } - }} + fill={fillBattlePlan} /> )} {g.battle.preLeader && !g.battle.preLeader.closed ? ( diff --git a/components/truthtrance.tsx b/components/truthtrance.tsx index 8d853bb4..3aab2551 100644 --- a/components/truthtrance.tsx +++ b/components/truthtrance.tsx @@ -581,7 +581,7 @@ export function Truthtrance({ - +