Support current battle choice promises and persistent notices
Verify and publish checkpoint container / container (push) Successful in 11m42s
Verify and publish checkpoint container / container (push) Successful in 11m42s
This commit is contained in:
1 parent
77d02b3231
commit
bd8377d87b
16 files changed
+684
-32
No files matched your search
@@ -0,0 +1,18 @@
|
||||
'use client';
|
||||
|
||||
import type { ActionableNotice as Notice } from '@/lib/actionable-notices';
|
||||
import { Button } from './ui/button';
|
||||
|
||||
/** Dismissal is local and never sends a game action. */
|
||||
export function ActionableNotice({ notice, onDismiss }: {
|
||||
notice: Notice | null;
|
||||
onDismiss: (id: number) => void;
|
||||
}) {
|
||||
if (!notice) return null;
|
||||
return <span className="block space-y-2" aria-live="polite">
|
||||
<span className="block">{notice.text}</span>
|
||||
<Button type="button" variant="outline" className="min-h-11" onClick={() => onDismiss(notice.id)}>
|
||||
Continue
|
||||
</Button>
|
||||
</span>;
|
||||
}
|
||||
@@ -31,6 +31,16 @@ const leaders = (game: GameView, target: string) => {
|
||||
const currentLot = (game: GameView) => game.bidPromiseLot?.turn === game.turn ? game.bidPromiseLot : null;
|
||||
const partners = (game: GameView, target: string) => game.players.some(player => player.id === target)
|
||||
? game.players.filter(player => player.id !== target) : [];
|
||||
/** Public unresolved pairs only; the current chooser owns exactly one choice. */
|
||||
const currentBattleChoices = (game: GameView, respondent: string) => {
|
||||
if (game.status !== 'playing' || game.phase !== 6 || game.battle ||
|
||||
game.active !== respondent || !game.battleOrder?.event) return [];
|
||||
return game.battleChoices.filter(choice => choice.chooser === respondent &&
|
||||
[choice.attacker, choice.defender].includes(respondent)).map(choice => ({
|
||||
source: game.battleOrder!.event, territory: choice.territory,
|
||||
target: choice.attacker === respondent ? choice.defender : choice.attacker,
|
||||
}));
|
||||
};
|
||||
const currentNexus = (game: GameView, target: string) => game.status === 'playing' && game.phase === 1 && game.nexus && !game.spiceWindow &&
|
||||
game.alliancePromiseNexus?.turn === game.turn && game.truthMixedAllianceTargets.includes(target) &&
|
||||
!game.response && !game.decision && !game.phaseOpening && !game.automaticContinuationPending;
|
||||
@@ -95,6 +105,7 @@ const config: MixedActionConfig<TurnActionLeaf> = {
|
||||
A remaining alliance condition settles at the actual close; forming an alliance does not fulfill it early.
|
||||
No can allow temporary membership followed by a break before the close. You cannot promise another player's consent.
|
||||
Battle-plan conditions concern one actual native plan in this current battle, including a plan already sealed or revealed.
|
||||
Battle-choice conditions concern the chooser’s next actual selection from the current unresolved pairs, before either plan.
|
||||
An open plan commitment settles when both plans are revealed, not merely when your own plan is sealed.
|
||||
Traitor conditions concern one original Reveal or decline declaration in the current revealed battle.
|
||||
The declaration counts before a later Karama or betrayal response can prevent its effect.
|
||||
@@ -168,6 +179,9 @@ const config: MixedActionConfig<TurnActionLeaf> = {
|
||||
throw new Error('Choose a public native leader for the respondent’s faction.');
|
||||
if (action.kind === 'alliance' && (!currentNexus(game, target) || !partners(game, target).some(partner => partner.id === action.partner)))
|
||||
throw new Error('Choose a public other partner during the current open Nexus.');
|
||||
if (action.kind === 'battleChoice' && !currentBattleChoices(game, target).some(choice =>
|
||||
choice.source === action.source && choice.territory === action.territory && choice.target === action.target))
|
||||
throw new Error('Choose one of the respondent’s actual current unresolved battles.');
|
||||
if (action.kind === 'battlePlan' || action.kind === 'traitorCall') {
|
||||
const battle = currentBattle(game, target, action.kind);
|
||||
if (!battle || action.battle !== battle.event || action.territory !== battle.territory)
|
||||
@@ -188,6 +202,7 @@ const config: MixedActionConfig<TurnActionLeaf> = {
|
||||
},
|
||||
renderAction: ({ value, id, game, target, disabled, onChange }) => {
|
||||
const choices = recipients(game, target), leaderChoices = leaders(game, target), lot = currentLot(game), partnerChoices = partners(game, target);
|
||||
const battleChoices = currentBattleChoices(game, target);
|
||||
const currentPower = value.kind === 'battlePower' ? powerOpportunity(game, target, value.claim) : null;
|
||||
const currentWindow = value.kind === 'windowCardPlay'
|
||||
? windowOpportunity(game, target, value.effect) : null;
|
||||
@@ -212,6 +227,8 @@ const config: MixedActionConfig<TurnActionLeaf> = {
|
||||
const claim = newPowerClaim(game, target), opportunity = powerOpportunity(game, target, claim);
|
||||
onChange({ kind, battle: opportunity?.event ?? '', territory: opportunity?.territory ?? '', claim });
|
||||
}
|
||||
if (kind === 'battleChoice') onChange({kind, source:battleChoices[0]?.source ?? '',
|
||||
territory:battleChoices[0]?.territory ?? '', target:battleChoices[0]?.target ?? ''});
|
||||
if (kind === 'battlePlan') onChange({ kind, battle: game.battle?.event ?? '', territory: game.battle?.territory ?? '',
|
||||
claim: { kind: 'dial', compare: 'eq', value: 0 } });
|
||||
if (kind === 'traitorCall') onChange({ kind, battle: game.battle?.event ?? '', territory: game.battle?.territory ?? '', call: true });
|
||||
@@ -227,6 +244,7 @@ const config: MixedActionConfig<TurnActionLeaf> = {
|
||||
<option value="cardPlay">Use a named printed card role after this answer</option>
|
||||
<option value="windowCardPlay">Use a printed card in this original native window or shipment-price opportunity</option>
|
||||
<option value="battlePower">Declare native Voice or Prescience in this battle</option>
|
||||
<option value="battleChoice">Choose the next unresolved battle</option>
|
||||
<option value="battlePlan">Use an actual current battle-plan choice</option>
|
||||
<option value="traitorCall">Make the current Traitor declaration</option>
|
||||
<option value="alliance">End this Nexus allied with a named partner</option>
|
||||
@@ -237,7 +255,25 @@ const config: MixedActionConfig<TurnActionLeaf> = {
|
||||
<option value="ship">Ship from reserves</option>
|
||||
<option value="move">Make ground movement</option>
|
||||
</select>
|
||||
{value.kind === 'stormDial' ? (() => {
|
||||
{value.kind === 'battleChoice' ? <>
|
||||
<label htmlFor={`${id}-battle-choice`}>Current unresolved battle</label>
|
||||
<select id={`${id}-battle-choice`} disabled={disabled}
|
||||
value={JSON.stringify([value.territory,value.target])}
|
||||
aria-invalid={!battleChoices.some(choice => choice.source === value.source && choice.territory === value.territory && choice.target === value.target)}
|
||||
onChange={event => {
|
||||
const selected = battleChoices.find(choice => JSON.stringify([choice.territory,choice.target]) === event.currentTarget.value);
|
||||
if (selected) onChange({kind:'battleChoice',...selected});
|
||||
}}>
|
||||
{!battleChoices.some(choice => choice.source === value.source && choice.territory === value.territory && choice.target === value.target) &&
|
||||
<option value={JSON.stringify([value.territory,value.target])}>Choose an available battle</option>}
|
||||
{battleChoices.map(choice => <option key={JSON.stringify([choice.territory,choice.target])}
|
||||
value={JSON.stringify([choice.territory,choice.target])}>
|
||||
{game.combatLocations.find(location => location.id === choice.territory)?.name ?? choice.territory}
|
||||
{' · '}{game.players.find(player => player.id === choice.target)?.name ?? choice.target}
|
||||
</option>)}
|
||||
</select>
|
||||
<p className="fine">Only this chooser’s actual next selection counts; later battles and another player’s choice do not.</p>
|
||||
</> : value.kind === 'stormDial' ? (() => {
|
||||
const opportunity = nativeStormDialOpportunity(game, target, value.source);
|
||||
return <>
|
||||
<p className="fine">The respondent’s original current Storm dial counts once. Other dials remain sealed until reveal.</p>
|
||||
|
||||
@@ -57,6 +57,7 @@ export function TurnActionGuideButton(props: TurnActionProps) {
|
||||
if (!guide) return null;
|
||||
const actor = game.me, turn = game.turn, phase = game.phase, event = guide.event, action = guide.action;
|
||||
const act = props.act, fillPlan = props.fillPlan, battle = game.battle;
|
||||
const chooserSource = action.type === 'chooseBattle' ? game.battleOrder?.event : null;
|
||||
const charity = game.charity;
|
||||
const charityOwner = action.type === 'charity' ? game.players.find(player => player.id === actor) : undefined;
|
||||
const charitySource = (current: GameView) => {
|
||||
@@ -504,6 +505,11 @@ export function TurnActionGuideButton(props: TurnActionProps) {
|
||||
const battlePreparation = genericCard && planWindow;
|
||||
const declaration = action.type === 'traitorCall' && typeof action.call === 'boolean' && !!battle && currentBattle && battle.revealed &&
|
||||
battle.traitorVoters.includes(actor) && !battle.traitorSubmitted.includes(actor);
|
||||
const chooseBattle = action.type === 'chooseBattle' && phase === 6 && !current.battle &&
|
||||
current.active === actor && !!chooserSource && current.battleOrder?.event === chooserSource &&
|
||||
Object.keys(action).every(key => ['type','territory','target','turnActionPromiseEvent','turnActionPromisePhase'].includes(key)) &&
|
||||
current.battleChoices.some(choice => choice.chooser === actor && choice.territory === action.territory &&
|
||||
(choice.attacker === actor ? choice.defender : choice.attacker) === action.target);
|
||||
const charityClaim = action.type === 'charity' && phase === 2 && !!me && me === charityOwner &&
|
||||
Object.keys(action).every(key => ['type', 'turnActionPromiseEvent', 'turnActionPromisePhase'].includes(key)) &&
|
||||
!current.ready.includes(actor) && me.charityClaimed === false && current.charity === charity &&
|
||||
@@ -523,7 +529,7 @@ export function TurnActionGuideButton(props: TurnActionProps) {
|
||||
Object.keys(action).every(key => ['type', 'amount', 'turnActionPromiseEvent', 'turnActionPromisePhase'].includes(key)) &&
|
||||
typeof action.amount === 'number' && Number.isSafeInteger(action.amount) &&
|
||||
action.amount >= stormDialSource.min && action.amount <= stormDialSource.max;
|
||||
const opportunity = currentStormDial || nativeSemuta || printedResidual || printedDistrans || printedSapho || printedBox || openingReady || earlyWindowReady || earlyWindowBox || printedWindow || ownedPower || payment || paidBox || printedHajr || printedGhola || plan || battlePreparation || declaration || nexusWindow && (ownedAlliance || action.type === 'ready') || (phase === 2
|
||||
const opportunity = currentStormDial || nativeSemuta || printedResidual || printedDistrans || printedSapho || printedBox || openingReady || earlyWindowReady || earlyWindowBox || printedWindow || ownedPower || payment || paidBox || printedHajr || printedGhola || plan || battlePreparation || declaration || chooseBattle || nexusWindow && (ownedAlliance || action.type === 'ready') || (phase === 2
|
||||
? charityClaim || !current.ready.includes(actor) && (action.type === 'ready' || genericCard)
|
||||
: phase === 3
|
||||
? invoice || nativePass || requiredBid || action.type === 'passBid' && !current.richeseAuction && currentAuction && current.auction?.active === actor
|
||||
@@ -585,6 +591,7 @@ export function TurnActionGuideButton(props: TurnActionProps) {
|
||||
: action.type === 'move' && flightInitial ? `Declare Ornithopter ${action.ornithopter === 'range3' ? 'three-territory' : 'two-group'} flight and move ${amount} physical forces to ${destination}${sector} while honoring your whole answer`
|
||||
: action.type === 'card' && windowEffect ? `Play ${windowRoleNames[windowEffect]} in its original native window${windowEffect === 'weather' ? ` with storm distance ${amount}` : ''} while honoring your whole answer`
|
||||
: action.type === 'battlePlan' ? 'Fill the quoted battle plan for review before sealing'
|
||||
: action.type === 'chooseBattle' ? `Choose the battle against ${recipient} in ${destination} while honoring your whole answer`
|
||||
: action.type === 'voice' ? `Declare native Voice: opponent ${action.must ? 'must' : 'cannot'} play ${battleCardLabel(String(action.kind))}`
|
||||
: action.type === 'prescience' ? `Request the ${String(action.field)} field with native Prescience while honoring your whole answer`
|
||||
: action.type === 'declineBattlePower' ? `Explicitly decline native ${power === 'voice' ? 'Voice' : 'Prescience'} while honoring your whole answer`
|
||||
|
||||
Reference in new issue
Block a user