Files
Dune/components/residual-poison.tsx
T
Quintine 9b67a780eb Connect early Juice of Sapho battle aggressor
During the existing public pre-plan opportunity, the holder can discard canonical unreserved Sapho to become aggressor before their readiness or any binding plan/Voice/inspection/Truthtrance commitment. Unchosen preparation prompts remain available. No new confirmation-only or holder-dependent response window is introduced. Later intervention and its allocation/privacy protocol remain unfinished.

A battle/turn/revision-bound history and independent event list preserve accepted priority while keeping attacker, defender and chooser stable. Legitimately recovered cards can change priority again at a fresh event. Reads, actions and normalization reject corrupt histories/custody. Shared tie priority respects Habbanya in either physical slot and reaches pre-commit Stone/Voice checks, public views, bot calculations and actual ordinary/Stone resolution. The final quote previously assumed original attacker priority and now consumes the validated aggressor. Harkonnen capture still follows actual winner/loser.

Owner controls, public aggressor/tie text, automatic notices and internal guidance are connected. Focused tests exercise actual tied results in Basic/Advanced, both Habbanya sides, mixed-force Stone finishability before opposing commitments, a real allied Prescience boundary, stale/late/cross-owner rejection, private rival noninterference, receipt corruption, saved recovered-card revision, actual policies at all four AI levels and authenticated SQLite races/seat restoration. Independent review found no material defect. A prior scheduling test now explicitly readies its human holder to save the card instead of allowing the new legal AI play.

Types, lint and 4866 offline tests, production build and 43 HTTP/session tests pass on the unchanged source fingerprint below. Two genuine CHOAM/Richese samples completed with 1279 accepted actions, 34 periodic JSON restores and no rejected candidates. One movement Sapho play occurred; neither sample used aggressor. Targeted tests and browser evidence, not those samples, establish the new effect. Full expansion and module acceptance remain incomplete.

In a new isolated browser room, genuine Advanced faction setup was followed by conserved battle staging. The human Guild used the actual aggressor button, restored the spent card and priority after refresh, readied, selected Master Bewt with zero dial/support, and declined a Traitor call. The staged Emperor opponent used real engine ready/plan/vote actions with Caid and zero dial/support. Guild won the 3-3 tie, retained four forces and 30 spice, and Emperor lost four forces. Final refresh and private JSON views restored the same outcome; the original seat row is unchanged. Screenshot capture timed out, so visual screenshot acceptance is not claimed.

All 1072 original games and original seat/recovery/entry/handover records are unchanged; 1106 rooms remain including isolated QA and HTTP fixtures. SQLite quick-check and foreign keys pass. The healthy server was reused without reset/restart or automation.

The Mirror audit now records why every genuine CHOAM/Richese setup includes unresolved copy candidates: an ordinary-copy-only gate would need hidden eligibility or altered inventory. Mirror stays gated pending the existing disposal ruling and copied-choice work. No mode/publication gate is opened.

Verified source tree: 2fb3160efd713a3f7068aedb474868ba6863bccc420848a56e69e1df1d84441b
2026-09-20 11:45:47 +10:00

132 lines
4.2 KiB
TypeScript

'use client';
import { useId } from 'react';
import type { Action, GameView } from '@/game/engine';
import { Button } from './ui/button';
import { CardInspector, CardRules } from './card-inspector';
type PreparationProps = {
game: GameView;
act: (action: Action) => void;
busy: boolean;
};
export function ResidualPoison({ game, act, busy }: PreparationProps) {
const id = useId();
const poison = game.residualPoison;
if (!poison) return null;
const target = game.players.find((player) => player.id === poison.target);
const reason =
poison.blocked ??
(!target || !poison.event
? 'Use this card against your opponent before battle leaders are chosen.'
: null);
return (
<details className="my-4 min-w-0">
<summary className="min-h-11 cursor-pointer py-3">
Residual Poison: before choosing leaders
</summary>
<div className="flex min-w-0 flex-col gap-4 py-3">
<p>
Play against your actual battle opponent. One available opposing
leader is randomly sent to the Tanks, with no spice bounty, then
Residual Poison is discarded. You do not choose the leader.
</p>
<CardRules card={poison.card} />
<CardInspector card={poison.card} />
{reason && (
<p className="notice" id={`${id}-reason`}>
{reason}
</p>
)}
<Button
className="min-h-11 whitespace-normal motion-reduce:transition-none"
disabled={busy || !!reason}
aria-describedby={reason ? `${id}-reason` : undefined}
onClick={() => {
if (!busy && !reason && poison.target && poison.event)
act({
type: 'card',
card: poison.card.id,
target: poison.target,
event: poison.event,
});
}}
>
Play Residual Poison against {target?.name ?? 'your battle opponent'}
</Button>
</div>
</details>
);
}
/** Neutral public timing controls must never depend on either player's hand. */
export function BattleLeaderOpportunity({ game, act, busy }: PreparationProps) {
const id = useId(),
battle = game.battle,
stage = battle?.preLeader;
if (!battle || !stage || stage.closed) return null;
const combatants = [battle.attacker, battle.defender];
const mine = combatants.includes(game.me),
ready = stage.ready.includes(game.me);
const interrupted = !!(
game.truthtrance ||
game.response ||
game.decision ||
game.phaseOpening
);
return (
<section
className="my-4 flex min-w-0 flex-col gap-3"
aria-labelledby={`${id}-heading`}
>
<h3 id={`${id}-heading`}>Before choosing battle leaders</h3>
<p>
Both combatants have an opportunity to use available preparations before
either commits a leader. Continue when you are ready to choose leaders.
{' '}A held Juice of Sapho can make you aggressor during this opportunity.
</p>
<ul>
{combatants.map((player) => (
<li key={player}>
{game.players.find((p) => p.id === player)?.name ?? 'Combatant'}:{' '}
{stage.ready.includes(player)
? 'Ready to choose leaders'
: 'Preparing'}
</li>
))}
</ul>
{mine &&
(!ready ? (
<>
{interrupted && (
<p className="notice" id={`${id}-reason`}>
Resolve the current interaction before continuing.
</p>
)}
<Button
className="min-h-11 whitespace-normal motion-reduce:transition-none"
disabled={busy || interrupted}
aria-describedby={interrupted ? `${id}-reason` : undefined}
onClick={() => {
if (!busy && !interrupted)
act({ type: 'battlePreparationReady', event: stage.event });
}}
>
Ready to choose leaders
</Button>
</>
) : (
<p className="fine">
You are ready. Waiting for the other combatant.
</p>
))}
{!mine && (
<p className="fine">
Waiting for the combatants to finish preparation.
</p>
)}
</section>
);
}