28 lines
1.3 KiB
TypeScript
28 lines
1.3 KiB
TypeScript
'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>;
|
|
}
|