'use client'; import { useState } from 'react'; import type { Action, GameView } from '@/game/engine'; import { nexusEmperorPurchaseAction, nexusEmperorRevivalAction } from '@/game/nexus-emperor-secret-ally-options'; import { Button } from '@/components/ui/button'; export function NexusEmperorSecretAlly({ game, act, busy, }: { game: GameView; act: (action: Action) => void; busy: boolean; }) { const [selectedElite, setSelectedElite] = useState(null); const offer = game.nexusEmperorSecretAlly; const owner = game.players.find((player) => player.id === game.me); const emperorSeated = game.players.some((player) => player.faction === 'emperor'); const purchase = offer?.purchase && game.nexusCards?.card === 'emperor' && !!owner && !emperorSeated && game.status === 'playing' && game.phase === 3 && game.decision?.kind === 'auctionPayment' && game.decision.player === game.me ? offer.purchase : null; if (purchase) { const action = nexusEmperorPurchaseAction(game); const blocked = busy || !action; const reason = purchase.blocked ?? (!action ? (owner?.spice ?? 0) < purchase.price ? `You need ${purchase.price} spice in your own supply for this bid.` : 'Finish the current interaction before spending the Emperor Nexus card.' : null); return (

Emperor Secret Ally

Your final bid is {purchase.price} spice. You must have all {purchase.price} spice in your own supply without ally aid. Spend the Emperor Nexus card to keep that spice instead of paying the bank; you receive the auction card normally.

{reason &&

{reason}

}
); } const eligible = offer?.revival && game.nexusCards?.card === 'emperor' && !!owner && !owner.ally && !emperorSeated && game.status === 'playing' && game.phase === 4 && !game.response && !game.decision && !game.truthtrance && !game.phaseOpening && !game.automaticContinuationPending && game.nexusCards.waiting.length === 0 && !game.nexusTraitors?.pending; if (!eligible) return null; const options = offer.revival.eliteOptions; const elite = options.length === 1 ? options[0] : selectedElite !== null && options.includes(selectedElite) ? selectedElite : null; const action = elite === null ? null : nexusEmperorRevivalAction(game, elite); const blocked = busy || !action; return (

Emperor Secret Ally

Spend the Emperor Nexus card to request exactly 3 additional forces for free through the normal revival continuation, beyond ordinary force/free allowances. Native typed caps and prevention still apply; Recruits does not double this grant.

{offer.revival.blocked &&

{offer.revival.blocked}

} {offer.revival.policy &&

{offer.revival.policy}

} {options.length > 1 && ( )}
); }