26 lines
1.2 KiB
TypeScript
26 lines
1.2 KiB
TypeScript
'use client';
|
|
|
|
import type {Action, GameView} from '@/game/engine';
|
|
|
|
/** This notice remains visible even when the Emperor has no spice to share. */
|
|
export function EmperorPhaseOpeningPriority({game, act, busy}: {
|
|
game: Pick<GameView, 'emperorPhaseOpeningPriority' | 'players'>;
|
|
act: (action:Action) => void;
|
|
busy: boolean;
|
|
}) {
|
|
const priority = game.emperorPhaseOpeningPriority;
|
|
if (!priority) return null;
|
|
const event = priority.event;
|
|
const recipient = game.players.find(player => player.id === priority.recipient)?.name ?? 'their ally';
|
|
const canContinue = !busy && priority.canContinue && !!event;
|
|
return <section className="notice space-y-3" aria-label="Emperor phase opening opportunity" aria-live="polite">
|
|
<h3>Emperor alliance opportunity</h3>
|
|
<p>Before the phase begins, the Emperor may share spice with {recipient}.</p>
|
|
{priority.canContinue
|
|
? <button type="button" className="game-action" disabled={!canContinue}
|
|
onClick={() => {if (canContinue && game.emperorPhaseOpeningPriority === priority && priority.canContinue && priority.event === event)
|
|
act({type:'emperorPhaseOpeningContinue', event});}}>Continue to phase</button>
|
|
: <p>Waiting for the Emperor to continue.</p>}
|
|
</section>;
|
|
}
|