Allow Advanced Emperor gifts during Guild rate responses
Verify and publish checkpoint container / container (push) Successful in 11m3s
Verify and publish checkpoint container / container (push) Successful in 11m3s
This commit is contained in:
1 parent
b3843bf18e
commit
5e7f7b45e4
14 files changed
+475
-6
No files matched your search
@@ -0,0 +1,27 @@
|
||||
'use client';
|
||||
|
||||
import type {Action, GameView} from '@/game/engine';
|
||||
|
||||
/** A public, balance-independent opportunity for the Emperor's ally gift. */
|
||||
export function EmperorGuildRatePriority({game, act, busy}: {
|
||||
game: Pick<GameView, 'emperorGuildRatePriority' | 'players'>;
|
||||
act: (action:Action) => void;
|
||||
busy: boolean;
|
||||
}) {
|
||||
const priority = game.emperorGuildRatePriority;
|
||||
if (!priority) return null;
|
||||
const event = priority.event;
|
||||
const recipient = game.players.find(player => player.id === priority.recipient)?.name ?? 'their ally';
|
||||
const canContinue = () => !busy && game.emperorGuildRatePriority === priority &&
|
||||
priority.canContinue && priority.event === event && typeof event === 'string' && event.length > 0;
|
||||
return <section className="notice space-y-3" aria-label="Emperor Guild rate opportunity" aria-live="polite">
|
||||
<h3>Emperor alliance opportunity</h3>
|
||||
<p>Before the Guild rate response continues, the Emperor may share spice with {recipient}.</p>
|
||||
{priority.canContinue
|
||||
? <button type="button" className="game-action" disabled={!canContinue()}
|
||||
onClick={() => {if (canContinue()) act({type:'emperorGuildRateContinue', event});}}>
|
||||
Continue to Guild rate
|
||||
</button>
|
||||
: <p>Waiting for the Emperor to continue.</p>}
|
||||
</section>;
|
||||
}
|
||||
@@ -14,7 +14,8 @@ export function EmperorTimingGift({ game, act, busy }: {
|
||||
const [raw, setRaw] = useState('1');
|
||||
const phaseOpening = game.emperorPhaseOpeningGift;
|
||||
const extortion = game.emperorExtortionGift;
|
||||
const offer = phaseOpening ?? extortion ?? game.emperorGuildTimingGift;
|
||||
const guildRate = game.emperorGuildRateGift;
|
||||
const offer = phaseOpening ?? extortion ?? guildRate ?? game.emperorGuildTimingGift;
|
||||
if (!offer) return null;
|
||||
const amount = /^[1-9]\d*$/.test(raw) ? Number(raw) : NaN;
|
||||
const canShare = !busy && Number.isSafeInteger(amount) && amount >= 1 && amount <= offer.maximum;
|
||||
@@ -26,7 +27,9 @@ export function EmperorTimingGift({ game, act, busy }: {
|
||||
? 'Phase opening resumes after the Karama response to your gift.'
|
||||
: extortion
|
||||
? 'The Moritani Extortion decision resumes after the Karama response to your gift.'
|
||||
: 'The Guild timing decision resumes after the Karama response to your gift.'}</p>
|
||||
: guildRate
|
||||
? 'The original Guild rate response resumes after the Karama response to your gift.'
|
||||
: 'The Guild timing decision resumes after the Karama response to your gift.'}</p>
|
||||
<label htmlFor={`${id}-amount`}>Spice to share</label>
|
||||
<input id={`${id}-amount`} type="number" inputMode="numeric" min={1} max={offer.maximum}
|
||||
step={1} value={raw} disabled={busy} onChange={event => setRaw(event.target.value)} />
|
||||
|
||||
@@ -297,6 +297,7 @@ import { RosterAlliance } from './roster-alliance';
|
||||
import { CoalitionFunding, coalitionFundingContributions, type CoalitionFundingContribution } from './coalition-funding';
|
||||
import { CoalitionEmperorAid } from './coalition-emperor-aid';
|
||||
import { EmperorTimingGift } from './emperor-timing-gift';
|
||||
import { EmperorGuildRatePriority } from './emperor-guild-rate-priority';
|
||||
import { EmperorAuctionGift } from './emperor-auction-gift';
|
||||
import { NexusEmperorPayment } from './nexus-emperor-payment';
|
||||
import { NexusEmperorSellerPurchase } from './nexus-emperor-seller-purchase';
|
||||
@@ -2607,6 +2608,8 @@ export function GameTable({
|
||||
) : g.response ? (
|
||||
<>
|
||||
<span className="eyebrow">Power response</span>
|
||||
<EmperorTimingGift game={g} act={act} busy={busy} />
|
||||
<EmperorGuildRatePriority game={g} act={act} busy={busy} />
|
||||
<h2>
|
||||
{
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user