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
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import { applyAction, type Game } from '../game/engine';
|
|
import type { Card } from '../game/cards';
|
|
import { leaderSkillBattle } from './leader-skill-battle-fixture';
|
|
|
|
/** Genuine skill assignment and conserved battle staging; returns before sealing plans. */
|
|
export function diplomatDefenseGame(hide = false, advanced = false): Game {
|
|
const game = leaderSkillBattle({
|
|
skill: 'diplomat',
|
|
unsealed: true,
|
|
hide,
|
|
advanced,
|
|
});
|
|
takeBattleCard(game, 'd', 'poison');
|
|
takeBattleCard(game, 'd', 'snooper');
|
|
return game;
|
|
}
|
|
|
|
export function takeBattleCard(
|
|
game: Game,
|
|
player: string,
|
|
kind: Card['kind'],
|
|
): Card {
|
|
const index = game.deck.findIndex((card) => card.kind === kind);
|
|
assert.ok(index >= 0, `Missing fixture ${kind}`);
|
|
const [card] = game.deck.splice(index, 1);
|
|
game.players.find((p) => p.id === player)!.hand.push(card);
|
|
return card;
|
|
}
|
|
|
|
export function revealDiplomatPlans(
|
|
game: Game,
|
|
slot: 'weapon' | 'defense' = 'defense',
|
|
): Game {
|
|
const own = game.players[0],
|
|
other = game.players[1];
|
|
let next = applyAction(game, 'a', {
|
|
type: 'battlePlan',
|
|
dial: 0,
|
|
leader: game.battle!.leaderSkillHidden?.a ? 'emperor-0' : 'emperor-1',
|
|
[slot]: own.hand.find((card) => card.kind === 'worthless')!.id,
|
|
});
|
|
next = applyAction(next, 'd', {
|
|
type: 'battlePlan',
|
|
dial: 0,
|
|
leader: 'guild-1',
|
|
weapon: other.hand.find((card) => card.kind === 'poison')!.id,
|
|
defense: other.hand.find((card) => card.kind === 'snooper')!.id,
|
|
});
|
|
return next;
|
|
}
|