Connect Harass & Withdraw to the battle preview

The independent Ecaz Treachery variant now supports Harass in either physical battle-card slot. A category-null Prescience answer keeps its identity private without erasing the selected card. Exact undialed normal/elite counters return before battle losses; opposing successful Traitors cancel withdrawal, ordinary leader deaths still resolve, and the card is discarded exactly once. Controls, all four AI profiles and saved continuation share the same physical quote. Existing Planetologist inspection and literal Truthtrance slot promises retain their meanings.

Unique Basic/Advanced physical allocations are supported. Ambiguous allocations, co-present Ecaz allied armies on either side, Richese card-family configurations and other optional modules remain gated before sealing from public/own context. The pending Stone Burner timing question is not assumed answered. Reveal-before-explosion order and mandatory disposal on an own-Traitor win are explicit source-timing/specificity inferences, consistent with existing Planetologist precedence. Reinforcements and full variant/public mode acceptance remain unfinished.

Independent rules/privacy/persistence review fixed asymmetric selector legality, misleading blocked-card guidance, invalid restored battle pairs, native-only inspection bypass and unsupported allied-army admission. Ixian fixtures preserve all seven physical cyborgs. The first broad run caught a semantic-status lint error in the blocked guidance; replacing the paragraph role with an output element fixed it. A subsequent broad run passed 4,775 of 4,776 tests and exposed an old UI assertion requiring category-null slots to be disabled. The updated regression verifies enabled category-null selectors exclude ordinary held cards, while exact leader/dial locks and submitted values remain bound; focused controls pass 14/14. No game source changed after the eight samples or browser replay. Types, lint, 4776 offline tests, build and 43 HTTP tests pass with unchanged source. Authenticated SQLite cases verify sealed private restoration and competing duplicate traitor actions with one physical resolution.

Eight fixed genuine six-seat games finish: basic/Easy: 1803 actions, 0 Harass plans, 0 withdrawals, 48 periodic restores; basic/Medium: 225 actions, 0 Harass plans, 0 withdrawals, 6 periodic restores; basic/Hard: 2184 actions, 1 Harass plans, 1 withdrawals, 59 periodic restores; basic/Brutal: 2073 actions, 1 Harass plans, 1 withdrawals, 56 periodic restores; advanced/Easy: 2057 actions, 1 Harass plans, 1 withdrawals, 55 periodic restores; advanced/Medium: 532 actions, 0 Harass plans, 0 withdrawals, 14 periodic restores; advanced/Hard: 538 actions, 0 Harass plans, 0 withdrawals, 14 periodic restores; advanced/Brutal: 544 actions, 0 Harass plans, 0 withdrawals, 14 periodic restores. All 218 game-source files match their source-stable runs; exact card/traitor/force custody and periodic/terminal private views are checked. Browser controls verify the full card, category None, Defense-first legality, actual sealing/reveal, four returned forces, ordinary leader death, disposal and refresh. A separate final-source replay verifies the conserved browser fixture and opposing continuation, including Face Dancer replacement. This is bounded playability evidence, not full compliance or AI calibration.

All 936 opening games and their original seat/recovery records remain unchanged (970 after checks); all 937 present immediately before checks are also preserved. Database integrity and foreign keys pass. The healthy server was reused after the power failure without restart, reset or recurring automation.

Verified source tree: be193613c455c5b76b49800fe3a7400504ea879af34c59621ade3d44f0fe019d
This commit is contained in:
Quintine committed 2026-09-14 04:41:30 +10:00
1 parent c04cb93830
commit 04501567d0
26 files changed
+2164 -127

No files matched your search

+45 -1
View File
@@ -13,6 +13,32 @@ import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import type { Action, GameView, PlanField } from '@/game/engine';
import type { CommittedPlanElement } from '@/game/battle-inspections';
import {
battleCardSlotEligible,
fixedBattleInspectionMatches,
validBattleSlotPair,
type BattleCardSlot,
} from '@/game/battle-card-slots';
import { canUsePlanetologistBattleSpecial } from '@/game/leader-skill-combat';
/** Both selectors evaluate the complete physical pair, in either selection order. */
export function battlePlanCardOptions(game: GameView, slot: BattleCardSlot, leader: string, weapon: string, defense: string) {
const me = game.players.find(player => player.id === game.me)!;
const fixed = battlePlanCommitments(game)[slot];
return (me.hand ?? []).filter(card => {
const w = slot === 'weapon' ? card : me.hand?.find(c => c.id === weapon);
const d = slot === 'defense' ? card : me.hand?.find(c => c.id === defense);
const planetologistWeapon = canUsePlanetologistBattleSpecial({
assignments: game.leaderSkills?.assignments.filter(a => a.controller === game.me) ?? [],
selectedLeader: leader, card: w,
});
return card.id !== 'ecaz-reinforcements' &&
(card.id !== 'ecaz-harass-withdraw' || (!!game.battle?.harassWithdraw && !game.battle.harassWithdraw.blocked)) &&
battleCardSlotEligible(slot, card, { planetologistWeapon }) &&
(!fixed || fixedBattleInspectionMatches(slot, fixed.value, card.id, card)) &&
validBattleSlotPair(w, d, planetologistWeapon);
});
}
/** Read only the recipient's projected commitments, including an explicit null. */
export function battlePlanCommitments(game: GameView): Partial<Record<PlanField, CommittedPlanElement>> {
@@ -30,7 +56,19 @@ export function battlePlanCommitments(game: GameView): Partial<Record<PlanField,
export function bindBattlePlanCommitments(game: GameView, plan: Action): Action {
if (plan.type !== 'battlePlan') return plan;
return { ...plan, ...Object.fromEntries(Object.values(battlePlanCommitments(game)).map((item) => [item.field, item.value])) };
return { ...plan, ...Object.fromEntries(Object.values(battlePlanCommitments(game)).map((item) => [item.field,
item.field === 'weapon' || item.field === 'defense'
? battlePlanCardValue(game, item.field, typeof plan[item.field] === 'string' ? plan[item.field] as string : '') || null
: item.value])) };
}
/** An inspected absence of a category still permits a legal slot-only Special. */
export function battlePlanCardValue(game: GameView, slot: BattleCardSlot, selected: string): string {
const commitment = battlePlanCommitments(game)[slot];
if (!commitment) return selected;
if (commitment.value !== null) return String(commitment.value);
const card = game.players.find((player) => player.id === game.me)?.hand?.find((card) => card.id === selected);
return card && fixedBattleInspectionMatches(slot, null, card.id, card) ? card.id : '';
}
export function battlePreparationField(game: GameView): PlanField | null {
@@ -222,6 +260,12 @@ export function BattlePreparation({
{beneficiary.name} will see this element. You may still change the rest
of your plan before sealing it.
</p>
{(field === 'weapon' || field === 'defense') && b.harassWithdraw && !b.harassWithdraw.blocked && (
<p className="fine">
Harass &amp; Withdraw is neither a weapon nor a defense. Choose None
for the category it will occupy; its identity stays private until plans are revealed.
</p>
)}
{b.voice && (
<p className="notice">
Voice: {b.voice.must ? 'must play' : 'cannot play'}{' '}
+26 -18
View File
@@ -117,10 +117,9 @@ import { FaceDanceDecision } from './face-dance-decision';
import { CHEAP_HERO_TRAITOR, matchingTraitor } from '@/game/traitors';
import {
battleCardLabel,
isWeaponCard,
isStoneBurner,
isDefenseCard,
} from '@/game/battle-cards';
import { validBattleSlotPair } from '@/game/battle-card-slots';
import { stoneBurnerPlanBlock } from '@/game/stone-burner';
import { TECH_TOKENS, ownedTech } from '@/game/tech-tokens';
import Link from 'next/link';
@@ -152,10 +151,11 @@ import {
} from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { BattlePreparation, battlePlanCommitments, bindBattlePlanCommitments, NexusInspectionHistory } from './battle-preparation';
import { BattlePreparation, battlePlanCommitments, battlePlanCardValue, battlePlanCardOptions, bindBattlePlanCommitments, NexusInspectionHistory } from './battle-preparation';
import { HarassWithdrawGuide, harassWithdrawControlState } from './harass-withdraw';
import { PrivateBattlePlan } from './private-battle-plan';
import { SpiceBankerControl, spiceBankerControlState } from './spice-banker';
import { canUsePlanetologistBattleSpecial, validLeaderSkillBattleCardPair } from '../game/leader-skill-combat';
import { canUsePlanetologistBattleSpecial } from '../game/leader-skill-combat';
import type { Card } from '../game/cards';
import { RevealedBattle } from './revealed-battle';
import { DiplomatDefense } from './diplomat-defense';
@@ -463,10 +463,19 @@ export function GameTable({
selectedLeader: committed.leader ? String(committed.leader.value ?? '') : leader,
card,
});
const selectedBattleWeapon = me.hand?.find(c => c.id === (committed.weapon ? committed.weapon.value : weapon));
const selectedWeaponId = battlePlanCardValue(g, 'weapon', weapon);
const selectedDefenseId = battlePlanCardValue(g, 'defense', defense);
const selectedBattleWeapon = me.hand?.find(c => c.id === selectedWeaponId);
const selectedBattleDefense = me.hand?.find(c => c.id === selectedDefenseId);
const battlePairValid = validBattleSlotPair(selectedBattleWeapon, selectedBattleDefense,
!!selectedBattleWeapon && planetologistSpecial(selectedBattleWeapon));
const harassControl = harassWithdrawControlState(g.battle?.harassWithdraw,
selectedWeaponId === 'ecaz-harass-withdraw' || selectedDefenseId === 'ecaz-harass-withdraw',
committed.dial ? Number(committed.dial.value) : battleDial,
me.faction === 'fremen' && !g.battle?.fremenSupportBlocked ? 0 : battleSupport);
const selectedStone = me.hand?.find(
(c) =>
c.id === (committed.weapon ? committed.weapon.value : weapon) &&
c.id === selectedWeaponId &&
isStoneBurner(c),
);
const stoneContext = g.battle?.stoneBurnerContext;
@@ -4579,24 +4588,19 @@ export function GameTable({
<select
id={`battle-${String(name).toLowerCase()}`}
value={
committed[name === 'Weapon' ? 'weapon' : 'defense']
? String(committed[name === 'Weapon' ? 'weapon' : 'defense']!.value ?? '')
: (v as string)
battlePlanCardValue(g, name === 'Weapon' ? 'weapon' : 'defense', v as string)
}
disabled={
!!committed[name === 'Weapon' ? 'weapon' : 'defense']
!!committed[name === 'Weapon' ? 'weapon' : 'defense'] &&
committed[name === 'Weapon' ? 'weapon' : 'defense']!.value !== null
}
onChange={(e) =>
(fn as (s: string) => void)(e.target.value)
}
>
<option value="">None</option>
{me.hand
?.filter((c) =>
name === 'Defense'
? isDefenseCard(c) && (!selectedBattleWeapon || !planetologistSpecial(selectedBattleWeapon) || validLeaderSkillBattleCardPair(selectedBattleWeapon,c,true))
: isWeaponCard(c) || planetologistSpecial(c),
)
{battlePlanCardOptions(g, name === 'Weapon' ? 'weapon' : 'defense',
selectedBattleLeader, selectedWeaponId, selectedDefenseId)
.map((c) => (
<option key={c.id} value={c.id}>
{c.name}{name === 'Weapon' && planetologistSpecial(c) ? ' · Planetologist +2, discard after battle' : ''}
@@ -4605,6 +4609,8 @@ export function GameTable({
</select>
</label>
))}
<HarassWithdrawGuide preview={g.battle.harassWithdraw} state={harassControl} />
{!battlePairValid && <p role="status" className="notice">Choose two compatible battle cards. A single physical card cannot fill both slots.</p>}
{selectedBattleWeapon && planetologistSpecial(selectedBattleWeapon) && (
<p className="notice">
{selectedBattleWeapon.name} adds 2 to the surviving Planetologist leader.
@@ -4691,7 +4697,7 @@ export function GameTable({
weapon,
defense,
}),
!!stonePlanReason,
!!stonePlanReason || !!harassControl.blocked || !battlePairValid,
)}
</>
) : (
@@ -4814,7 +4820,9 @@ export function GameTable({
(ecaz
? ecaz.card.effect === 'recruits'
? g.recruitsPreview?.play?.blocked ?? 'Use the Recruits panel during Revival to play this card.'
: 'This card’s battle effect is still being implemented.'
: ecaz.card.effect === 'harassWithdraw'
? g.battle?.harassWithdraw?.blocked ?? 'Use either battle-card slot to play Harass & Withdraw.'
: 'This card’s battle effect is still being implemented.'
: null) ??
(richese?.card.effect === 'distrans'
? 'Use the Distrans transfer panel above to choose a recipient and another card.'
+34
View File
@@ -0,0 +1,34 @@
import { quoteHarassWithdraw, type HarassWithdrawPreview } from '@/game/harass-withdraw';
export function harassWithdrawControlState(
preview: HarassWithdrawPreview | null | undefined,
selected: boolean,
dial: number,
support: number,
) {
if (!selected) return { blocked: null, returned: null };
if (!preview) return { blocked: 'Harass & Withdraw is not available in this battle.', returned: null };
try {
return { blocked: null, returned: quoteHarassWithdraw(preview, dial, support).returned };
} catch (error) {
return { blocked: error instanceof Error ? error.message : 'Choose a supported force commitment.', returned: null };
}
}
export function HarassWithdrawGuide({
preview, state,
}: {
preview: HarassWithdrawPreview | null | undefined;
state: ReturnType<typeof harassWithdrawControlState>;
}) {
if (!preview) return null;
return <section aria-label="Harass and Withdraw battle guidance" className="notice space-y-2">
<h4>Harass &amp; Withdraw</h4>
{preview.blocked || state.blocked
? <output className="block">{preview.blocked ?? state.blocked}</output>
: state.returned
? <p>Return {state.returned.normal} ordinary and {state.returned.elite} elite undialed forces to reserves when plans resolve.</p>
: <p>Select this card in either battle-card slot. Your undialed forces return to reserves.</p>}
<p>Your leader can still die. An opponent’s successful traitor call cancels the withdrawal. Discard this card after use.</p>
</section>;
}