Add the absent-Emperor Secret Ally alternative returning exactly three eligible forces free in Basic/Advanced base-faction Nexus games. Preserve ordinary force/free-revival allowances and the shared Advanced Fedaykin cap. Keep the action optional and private, consume the physical Nexus once, and validate durable source receipts through later ordinary revival and Ghola. Purchase timing remains pending the earlier uniform winner-payment UX question; partial returns and combined-module interactions remain guarded. No mode or publication gate opens. Connect private controls, explicit physical elite selection, all four legal AI profiles and a dedicated rules checklist entry. Extend the reusable local prototype writer with genuine twelve-card Nexus setup. Independent review covers rules timing, private projection, physical custody, JSON and production SQLite restore, lost-response replay and competing requests. Seventeen focused effect cases and four prototype-writer cases pass. Validation: typecheck, lint, 4649 offline tests, production build and 43 HTTP tests passed with unchanged source. Genuine-start Basic and Advanced samples completed in 715 and 263 actions with 19 and 7 periodic JSON restores, respectively, and no Emperor uses. Two explicitly staged continuations completed in 18 and 17 actions with one normal-force Emperor return each. All four had zero rejections and preserved exact Treachery, force, elite and Nexus custody; all fourteen final seat views restored unchanged. They are bounded continuation evidence, not natural full-game acceptance of the effect or AI calibration. In the conserved staged browser scenario, Advanced Fremen returned three forces including one Fedaykin using the Nexus, then three normal forces using the ordinary allowance. Reserves rose from three to nine, Tanks fell from seven to one, spice stayed three and the physical Nexus was spent once. The inspector was readable, the action notice displayed, and pending/resolved refresh restoration, physical custody and private projection passed. After the reported power outage, all 733 opening games and original seat/recovery records were preserved (767 after HTTP checks); database integrity and foreign keys passed. All 734 rooms immediately before broad verification remained unchanged. Reused the healthy server without restart, reset or recurring automation. Verified source tree: fd09a4bc71018cb7ef98c7e25c25dacc495ffed304dbd0cdfa223e539e8fa5e1
83 lines
2.9 KiB
TypeScript
83 lines
2.9 KiB
TypeScript
'use client';
|
|
|
|
import { useState } from 'react';
|
|
import type { Action, GameView } from '@/game/engine';
|
|
import { 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<number | null>(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 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 (
|
|
<section className="min-w-0 space-y-3" aria-label="Emperor Secret Ally revival">
|
|
<h3 className="font-serif text-xl">Emperor Secret Ally</h3>
|
|
<p className="text-base leading-7">
|
|
Spend the Emperor Nexus card to revive 3 additional forces for free,
|
|
beyond your ordinary revival quota. The elite cap still applies.
|
|
</p>
|
|
{offer.revival.blocked && <p className="notice">{offer.revival.blocked}</p>}
|
|
{options.length > 1 && (
|
|
<label className="block space-y-2">
|
|
<span className="font-semibold">Elite forces to revive</span>
|
|
<select
|
|
aria-label="Elite forces to revive"
|
|
className="min-h-11 w-full rounded border border-[#65644b] bg-[#171b17] px-3 py-2"
|
|
value={elite ?? ''}
|
|
disabled={busy || !!offer.revival.blocked}
|
|
onChange={(event) => setSelectedElite(event.currentTarget.value === '' ? null : Number(event.currentTarget.value))}
|
|
>
|
|
<option value="">Choose an elite count</option>
|
|
{options.map((count) => (
|
|
<option key={count} value={count}>{count}</option>
|
|
))}
|
|
</select>
|
|
</label>
|
|
)}
|
|
<Button
|
|
className="min-h-11 whitespace-normal"
|
|
disabled={blocked}
|
|
onClick={() => {
|
|
if (!blocked && action) act(action);
|
|
}}
|
|
>
|
|
Revive 3 additional forces{elite === null ? '' : ` · ${elite} elite`}
|
|
</Button>
|
|
</section>
|
|
);
|
|
}
|