Admit supported active or originally queued unused shipments during the current Shipment & Movement phase. Answering preserves the real active player and queue; private future reachability uses owned resources, joint whole promises and the actual respondent profile. Hide executable guidance until that owner is active. Keep native Guild WAIT/TAKE, frozen mixed facts, interception, costs and actual delivery. Do not release a waiting promise while another declaration is unresolved or count its approved ally contribution as freely recoverable. Before response declaration, reject Emperor gifts or optional BG accompaniment that remove the last legal completion; affordable options remain legal. Minimal AI declines optional accompaniment while bound rather than attempting to spend required reserves. No strategy tuning or new profile/module/earlier-phase opening. Validation and exact frozen-source evidence are recorded in the canonical Truthtrance shipment contract. Three real public Basic/Advanced programmes use original unopened starting deals, paid intervening turns and a later Emperor or native out-of-order Guild fulfillment. Four minimal policies answer while waiting and ship only on their actual turn. Controlled funding, temporary price, gift and advisor probes remain separate. Existing stale scope fixtures and two type declarations were repaired during feedback. Earlier phases, broader modules/actions, full Truthtrance/modes, final assurance and browser/deployed acceptance remain open. No saved-room/database/reset/restart/deployment operation.
127 lines
4.7 KiB
TypeScript
127 lines
4.7 KiB
TypeScript
'use client';
|
|
import type { Action, GameView } from '@/game/engine';
|
|
import { liveShipmentPromises, matchesShipment, shipmentClaimText } from '@/game/shipment-promises';
|
|
import { truthQuestionText } from '@/game/truthtrance';
|
|
import { CHEAP_HERO_TRAITOR } from '@/game/traitors';
|
|
import { territory } from '@/game/board';
|
|
import { reserveShipmentCost, guildShipmentCost } from '@/game/shipment-price';
|
|
import { Button } from './ui/button';
|
|
|
|
export function ShipmentPromises({
|
|
game: g,
|
|
act,
|
|
busy,
|
|
}: {
|
|
game: GameView;
|
|
act: (action: Action) => void;
|
|
busy: boolean;
|
|
}) {
|
|
const promises = liveShipmentPromises(g.shipmentPromises, g.me, g.turn);
|
|
if (!promises.length) return null;
|
|
const me = g.players.find((p) => p.id === g.me)!;
|
|
const next = g.shipmentCompletion?.actions[0];
|
|
const shipping = next && (next.type === 'ship' || next.type === 'guildShip');
|
|
const halfRate = g.karamaShipping?.player === me.id ||
|
|
(!g.guildRateCanceled &&
|
|
(me.faction === 'guild' ||
|
|
g.players.some((p) => p.faction === 'guild' && p.id === me.ally)));
|
|
const cost = shipping
|
|
? next.type === 'guildShip'
|
|
? guildShipmentCost(
|
|
String(next.territory) === 'reserves'
|
|
? 'reserves'
|
|
: territory(String(next.territory)).type,
|
|
Number(next.amount),
|
|
g.karamaShipping?.player === me.id || !g.guildRateCanceled,
|
|
)
|
|
: reserveShipmentCost(
|
|
{ faction: me.faction, halfRate },
|
|
territory(String(next.territory)).type,
|
|
Number(next.amount),
|
|
)
|
|
: null;
|
|
const share = shipping
|
|
? Number(next.allyPayment ?? Math.max(0, cost! - (me.spice ?? 0)))
|
|
: 0;
|
|
const elite = Number(next?.elite ?? 0);
|
|
const allocation =
|
|
elite > 0
|
|
? `, including ${elite} ${me.faction === 'emperor' ? 'Sardaukar' : me.faction === 'fremen' ? 'Fedaykin' : 'elite force' + (elite === 1 ? '' : 's')}`
|
|
: '';
|
|
const description = next
|
|
? shipping
|
|
? `Ship ${Number(next.amount)} forces${allocation} to ${territory(String(next.territory)).name}, sector ${Number(next.sector)}`
|
|
: next.type === 'pledgeAid'
|
|
? 'Reclaim your unused ally pledge'
|
|
: `Play ${me.hand?.find((c) => c.id === next.card)?.name ?? 'your preparation card'}${next.amount ? ` to revive ${Number(next.amount)} forces${allocation}` : ' for your shipment discount'}`
|
|
: '';
|
|
return (
|
|
<section
|
|
className="notice"
|
|
aria-label="Your Truthtrance shipment promises"
|
|
id="shipment-promise-guidance"
|
|
>
|
|
<h3>Your shipment promises</h3>
|
|
{g.active !== g.me && <p>
|
|
Your shipment turn is still ahead. This answer stays binding while
|
|
other players finish; shipment actions become available on your turn.
|
|
</p>}
|
|
<ul>
|
|
{promises.map((p, index) => (
|
|
<li key={index}>
|
|
You answered {p.answer ? 'Yes' : 'No'} to:{' '}
|
|
{p.mixed
|
|
? truthQuestionText(
|
|
{ kind: 'mixedShipment', target: p.player, mixed: p.mixed },
|
|
id => id === CHEAP_HERO_TRAITOR
|
|
? 'Cheap Hero / Heroine'
|
|
: g.allLeaders.find(leader => leader.id === id)?.name ?? id,
|
|
id => g.combatLocations.find(place => place.id === id)!.name,
|
|
)
|
|
: `Will you ${shipmentClaimText(p)} this turn?`}
|
|
</li>
|
|
))}
|
|
</ul>
|
|
{promises.some((p) => matchesShipment(p, null) !== p.answer) ? (
|
|
<p>
|
|
Complete a qualifying shipment before ground movement or finishing
|
|
your turn: skipping would not honor the whole claim you answered.
|
|
You can choose any legal count, sector and funding that honor all
|
|
your answers. Current facts remain fixed at the time of your answer.
|
|
</p>
|
|
) : (
|
|
<p>
|
|
Skipping shipment honors your whole claims. If you ship, choose a
|
|
legal shipment that honors every answer. Current facts are historical
|
|
and create no later card, spice or force holding obligation.
|
|
</p>
|
|
)}
|
|
{next && (
|
|
<details>
|
|
<summary>Suggested next step · private</summary>
|
|
<p>{description}.</p>
|
|
{cost !== null && (
|
|
<p>
|
|
Cost: {cost} spice · Your payment: {cost - share} · Ally pledge:{' '}
|
|
{share}.
|
|
</p>
|
|
)}
|
|
<Button
|
|
className="game-action"
|
|
disabled={
|
|
busy ||
|
|
!!g.truthtrance ||
|
|
!!g.response ||
|
|
!!g.decision ||
|
|
!!g.phaseOpening
|
|
}
|
|
onClick={() => act(next)}
|
|
>
|
|
{description}
|
|
</Button>
|
|
</details>
|
|
)}
|
|
</section>
|
|
);
|
|
}
|