Prototype native Diplomat base-defense copying
Allow one committed Worthless to copy an opposing base Shield or Snooper when no actual defense is played, including protection of the selected native trained leader. Expose an optional named public choice after both plans reveal, before traitor calls, and show the activated protection in revealed plans. Discard the chosen physical Worthless once after battle, including winner and traitor-preempted outcomes. Original physical card identities and plans stay intact. Timing and explicit-discard precedence are documented implementation inferences; lower retreat, modified defenses, combined modes and public starts remain guarded. Reuse legal Worthless planning candidates and add a public-information decision path for all four AI profiles. Bind new battle choices to revealed plans, public skill stance, canonical card custody and an independent event, validate saved continuations before reads/actions, omit internal proof fields from views, and retain unmarked legacy-battle behavior. Independent rules/privacy/persistence review found no blocker. Validation: focused Diplomat rules/UI/bot/JSON/SQLite checks plus 80 related legacy checks passed; typecheck, lint, 4537 offline tests, production build and 43 HTTP tests passed. Concurrent copy versus decline, stale/corrupt decisions, self-protection and mandatory traitor-winner discard are covered. Browser genuine assignment and a conserved staged battle exercised human plan submission, refresh of the pending choice, actual Snooper copying with Baliset, Hasimir survival, exactly one Baliset discard, ordinary Crysknife retention and final refresh with private cards and four board forces, fifteen reserves, one Tank and eight spice. Basic/Advanced four-profile samples completed in 210/223 actions with six/seven JSON restores and no rejected candidates; neither encountered an eligible copy, so targeted checks establish the effect. The server was healthy after the power outage. All 563 opening rooms and original seat/recovery records were preserved (597 after QA/HTTP); SQLite integrity and foreign keys passed. No restart, reset or automation was needed. Verified source tree: 868bb7484cef244e6ab20f8d08d62e118629e257870cf91a436bf42651b968f5
This commit is contained in:
1 parent
788453e07e
commit
f067950f5e
21 files changed
+1463
-25
No files matched your search
@@ -0,0 +1,62 @@
|
||||
'use client';
|
||||
|
||||
import type { Action, GameView } from '@/game/engine';
|
||||
import { battleCardLabel } from '@/game/battle-cards';
|
||||
import { Button } from './ui/button';
|
||||
|
||||
export function DiplomatDefense({
|
||||
game,
|
||||
act,
|
||||
busy,
|
||||
}: {
|
||||
game: GameView;
|
||||
act: (action: Action) => void;
|
||||
busy: boolean;
|
||||
}) {
|
||||
const decision =
|
||||
game.decision?.kind === 'diplomatDefense' ? game.decision : null;
|
||||
if (!decision || decision.player !== game.me) return null;
|
||||
const me = game.players.find((player) => player.id === game.me);
|
||||
const visibleCards = [...(game.battle?.cards ?? []), ...(me?.hand ?? [])];
|
||||
const card = (id: string) => visibleCards.find((entry) => entry.id === id);
|
||||
const source = card(decision.source);
|
||||
const copiedDefense = source ? battleCardLabel(source.kind) : 'defense';
|
||||
return (
|
||||
<div className="flex flex-col gap-3" aria-label="Diplomat defense choice">
|
||||
<p>
|
||||
The opposing committed defense,{' '}
|
||||
<strong>{source?.name ?? decision.source}</strong>, provides{' '}
|
||||
<strong>{copiedDefense}</strong> protection. Diplomat can copy that
|
||||
protection onto one of your committed Worthless cards.
|
||||
</p>
|
||||
<p className="fine">
|
||||
Choose one committed Worthless card as the copied defense. That card
|
||||
must be discarded after this battle. Decline to proceed without a copied
|
||||
defense.
|
||||
</p>
|
||||
{decision.cards.map((id) => (
|
||||
<Button
|
||||
key={id}
|
||||
className="game-action min-h-11 whitespace-normal"
|
||||
disabled={busy}
|
||||
onClick={() =>
|
||||
!busy && act({ type: 'decision', event: decision.event, card: id })
|
||||
}
|
||||
>
|
||||
Copy {source?.name ?? copiedDefense} with {card(id)?.name ?? id} ·
|
||||
mandatory discard
|
||||
</Button>
|
||||
))}
|
||||
<Button
|
||||
variant="outline"
|
||||
className="game-action min-h-11 whitespace-normal"
|
||||
disabled={busy}
|
||||
onClick={() =>
|
||||
!busy && act({ type: 'decision', event: decision.event, card: null })
|
||||
}
|
||||
>
|
||||
Decline Diplomat defense
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -152,6 +152,7 @@ import { SpiceBankerControl, spiceBankerControlState } from './spice-banker';
|
||||
import { canUsePlanetologistBattleSpecial, validLeaderSkillBattleCardPair } from '../game/leader-skill-combat';
|
||||
import type { Card } from '../game/cards';
|
||||
import { RevealedBattle } from './revealed-battle';
|
||||
import { DiplomatDefense } from './diplomat-defense';
|
||||
import { EliteCount } from './elite-count';
|
||||
import { HelpTip } from './help-tip';
|
||||
import { PHASE_HELP, phaseRuleId } from '@/game/reference';
|
||||
@@ -2135,6 +2136,8 @@ export function GameTable({
|
||||
? g.decision.stage === 'offer' ? 'Rihani Decipherer — optional draw' : 'Choose your Traitor exchange'
|
||||
: g.decision.kind === 'sukRescue'
|
||||
? 'Save your battle casualties'
|
||||
: g.decision.kind === 'diplomatDefense'
|
||||
? 'Copy an opposing defense'
|
||||
: g.decision.kind === 'homeworldRevivalDeployment'
|
||||
? 'Revival deployment'
|
||||
: g.decision.kind === 'ecazSpice'
|
||||
@@ -2546,6 +2549,11 @@ export function GameTable({
|
||||
mode: 'ignore',
|
||||
})}
|
||||
</>
|
||||
) : g.decision.kind === 'diplomatDefense' ? (
|
||||
<>
|
||||
<RevealedBattle game={g} />
|
||||
<DiplomatDefense game={g} act={act} busy={busy} />
|
||||
</>
|
||||
) : g.decision.kind === 'poisonTooth' ? (
|
||||
<>
|
||||
<RevealedBattle game={g} />
|
||||
|
||||
@@ -112,9 +112,12 @@ export function LeaderSkillsPanel({
|
||||
This development-only module currently connects the card-role strength
|
||||
modifiers for Warmaster, Master of Assassins, Swordmaster of Ginaz,
|
||||
Killer Medic and Prana-Bindu Adept, plus Planetologist movement and
|
||||
Special-card battle use, Suk Graduate force rescue, Mentat and Bureaucrat
|
||||
battle scores, Sandmaster ground-route collection and victory spice, Rihani inspections/exchanges, optional Smuggler reserve shipping and Spice Banker battle spending. Other Leader Skill effects are
|
||||
unfinished.
|
||||
Special-card battle use, Suk Graduate force rescue, Mentat and
|
||||
Bureaucrat battle scores, Sandmaster ground-route collection and
|
||||
victory spice, Rihani inspections and exchanges, optional Smuggler
|
||||
reserve shipping, Spice Banker battle spending, and Diplomat copying
|
||||
an opposing base defense with a committed Worthless card after plans
|
||||
are revealed. Other Leader Skill effects are unfinished.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ export function RevealedBattle({ game }: { game: GameView }) {
|
||||
<div className="revealed-plans" aria-label="Revealed battle plans">
|
||||
{Object.entries(battle.plans).map(([id, plan]) => {
|
||||
const leader = game.allLeaders.find((l) => l.id === plan.leader);
|
||||
const diplomat =
|
||||
battle.diplomatDefense?.player === id ? battle.diplomatDefense : null;
|
||||
const undialed = [
|
||||
...new Set(
|
||||
comparisons.flatMap(
|
||||
@@ -91,6 +93,15 @@ export function RevealedBattle({ game }: { game: GameView }) {
|
||||
</span>
|
||||
)}
|
||||
<span>Defense in original plan: {name(plan.defense)}</span>
|
||||
{diplomat?.stage === 'copied' && diplomat.card && (
|
||||
<span>
|
||||
Diplomat: {name(diplomat.card)} copies {name(diplomat.source)} ·
|
||||
discard after battle
|
||||
</span>
|
||||
)}
|
||||
{diplomat?.stage === 'declined' && (
|
||||
<span>Diplomat: defense copy declined</span>
|
||||
)}
|
||||
{battle.lateDefense[id] && (
|
||||
<span>Added after reveal: {name(battle.lateDefense[id])}</span>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user