'use client'; import type { Action, GameView } from '@/game/engine'; import { leaderRevivalClaimText, leaderRevivalPromiseModeSupported, liveLeaderRevivalPromises } from '@/game/leader-revival-promises'; import { Button } from './ui/button'; type LeaderRevivalPromiseProps = { game: GameView; busy: boolean; send: (action: Action) => void }; const leaderName = (game: GameView, id: string) => id === 'kwisatz' ? 'Kwisatz Haderach' : game.allLeaders.find(leader => leader.id === id)?.name ?? 'the named leader'; /** Forward the exact projected preparation or ordinary return packet. The * client does not reconstruct leader eligibility, cycle restrictions or cost. */ export function LeaderRevivalPromiseGuideButton(props: LeaderRevivalPromiseProps) { const game = props.game, guide = game.leaderRevivalPromiseGuide; if (!guide) return null; const actor = game.me, turn = game.turn, phase = guide.phase, order = game.revivalOrder; const action = guide.action, event = action.leaderRevivalPromiseEvent, signature = JSON.stringify(action); const canAct = () => { const current = props.game, me = current.players.find(player => player.id === current.me); const payment = phase === 3 && action.type === 'decision' && current.decision?.kind === 'auctionPayment' && current.decision.player === actor; const native = current.richeseAuction; const nativePass = phase === 3 && action.type === 'richeseBid' && native && native.event === action.event && !native.outcome && native.eligible.includes(actor) && (native.method === 'silent' ? !native.submitted.includes(actor) && action.amount === 0 : native.active === actor && action.amount === null) && action.allyPayment === 0; const request = current.revivalRequests[actor]; const acceptedQuote = action.type === 'acceptLeaderRevival' && !!request && !request.declined && typeof request.price === 'number' && request.price === action.leaderRevivalPrice; const opportunity = phase === 2 ? !current.ready.includes(actor) && (action.type === 'charity' || action.type === 'ready') : phase === 3 ? payment || nativePass || action.type === 'passBid' && !native && current.auction?.active === actor : phase === 4 && !current.ready.includes(actor) && (action.type === 'reviveLeader' || action.type === 'reviveKwisatz' || acceptedQuote || action.type === 'revive' || action.type === 'ready') && current.revivalOrder === order && (!current.revivalOrder || current.revivalOrder.turn === turn && current.revivalOrder.remaining[0] === actor && current.active === actor); return !props.busy && current === game && leaderRevivalPromiseModeSupported(current) && current.status === 'playing' && current.phase === phase && current.me === actor && current.turn === turn && opportunity && current.leaderRevivalPromiseGuide === guide && current.leaderRevivalPromiseGuide.phase === phase && current.leaderRevivalPromiseGuide.action === action && JSON.stringify(action) === signature && typeof event === 'string' && liveLeaderRevivalPromises(current.leaderRevivalPromises, actor, turn).some(promise => promise.event === event) && !!me && !me.autopilot && !current.truthtrance && !current.response && (!current.decision || payment) && !current.phaseOpening && !current.automaticContinuationPending && !current.roomControl?.paused && !current.roomControl?.closed; }; return ; } export function LeaderRevivalPromises(props: LeaderRevivalPromiseProps) { const own = props.game.leaderRevivalPromises.filter(promise => promise.player === props.game.me); if (!own.length) return null; const live = liveLeaderRevivalPromises(own, props.game.me, props.game.turn).length > 0; const other = props.game.revivalOrder?.remaining[0]; const waiting = live && (props.game.phase < 4 || props.game.phase === 4 && other && other !== props.game.me); return

Your leader Revival promises

Yes requires the named leader’s future actual ordinary native return while it remains possible. No forbids that named ordinary return until your Revival opportunity ends this turn. A request alone is not a return. Prior returns, Ghola, foreign leaders and special card returns do not count.

Original revival cycles, costs, limits and turn order still apply. Preparation may return forces or complete an earlier payment without returning the named leader. A guide may accept an existing, current Tleilaxu quote; it does not arrange a new agreement or promise future consent. {' '}Leader Revival promise rules.

{props.game.phase < 4 &&

Your leader Revival opportunity is still ahead. Continue the current phase and preserve its required resources; Charity and auction preparation do not themselves fulfill a named-leader answer.

} {waiting && props.game.phase === 4 &&

Your leader Revival opportunity is still ahead; this promise remains visible while the current actor finishes.

}
; }