Files
Dune/components/nexus-choam-trade.tsx
T
Quintine 4af6e08b3a Prototype CHOAM Nexus Collection trade and inventory Discoveries
An unallied player holding CHOAM Nexus while CHOAM is absent can now discard one Worthless card during Spice Collection for two bank spice. The server spends both physical cards once, exposes only private legal card choices, and persists an already-paid discard receipt. Human controls and all four AI profiles share the action. The after-victory inspection alternative remains missing; normal unfinished modes and publication stay gated.

Independent review caught and fixed a queued Grumman Collection lock mismatch. Focused tests cover Basic/Advanced, actual card custody, private controls, all AI profiles, stale and wrong-mode rejection, Truthtrance and Grumman locks, JSON corruption/replay, competing production SQLite writes and private seat restoration.

A separate bounded acquisition helper recorded all seven Discovery Spice Cards, eight tokens and exact physical card placements from publisher-authored sources. Discovery runtime remains missing.

Validation: types, lint, 4,217 offline tests, production build and 40 HTTP tests passed. Durations: check 139298 ms; build 6617 ms; HTTP 24329 ms. Source fingerprint dfdaaf8bafe69acd31c9d0afc13f7a0d070da43deb544f091e95fe840b399493; private report under ~/.local/share/dune/checkpoints/20260913-choam-nexus-trade/verification/report.json. Browser reference search, Prototyped label and related Collection link checked. All 95 opening saved rooms unchanged; 30 HTTP test rooms added, 125 total. No server restart or database reset.

Efficiency counter: 59,982,405 at batch start; 60,581,959 after broad verification, delta 599,554 aggregate tokens before final preservation/Git/usage checks. One newly playable function plus the acquired Discovery inventory; this is not full CHOAM or Nexus compliance.
2026-09-13 12:39:43 +10:00

37 lines
1.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use client';
import { useState } from 'react';
import type { Action, GameView } from '@/game/engine';
import { nexusChoamTradeAction } from '@/game/nexus-choam-trade-options';
import { CardInspector } from './card-inspector';
import { Button } from './ui/button';
type Props = { game: GameView; act: (action: Action) => void; busy: boolean };
export function NexusChoamTrade({ game, act, busy }: Props) {
const [selected, select] = useState('');
const offer = game.nexusChoamTrade;
if (!offer) return null;
const card = offer.cards.find(choice => choice.id === selected) ?? offer.cards[0];
const action = card ? nexusChoamTradeAction(game, card.id) : null;
return (
<section aria-label="CHOAM Nexus Secret Ally trade" className="space-y-3 rounded-lg border border-[#a88b60]/50 p-3">
<h3>CHOAM Nexus · Secret Ally</h3>
<p>During Spice Collection, discard one Worthless card to receive two spice from the bank. This also spends your CHOAM Nexus card.</p>
{offer.cards.length > 1 && (
<label className="block">Worthless card to trade
<select value={card.id} disabled={busy || !!offer.blocked} onChange={event => select(event.target.value)}>
{offer.cards.map(choice => <option key={choice.id} value={choice.id}>{choice.name}</option>)}
</select>
</label>
)}
{card && <div className="flex flex-wrap items-center gap-2"><span>{card.name}</span><CardInspector card={card} /></div>}
{offer.blocked && <p className="notice">{offer.blocked}</p>}
<Button className="game-action min-h-11 whitespace-normal" disabled={busy || !action}
onClick={() => { if (!busy && action) act(action); }}>
Trade {card?.name ?? 'a Worthless card'} for 2 spice
</Button>
<p className="fine">Optional: keep both cards by continuing the phase. This Nexus card’s battle inspection alternative is still in development.</p>
</section>
);
}