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
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user