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
239 lines
7.5 KiB
TypeScript
239 lines
7.5 KiB
TypeScript
import type { Card } from './cards';
|
|
import { richeseCardDefinition } from './richese-cards';
|
|
import {
|
|
resolveBattleWeapons,
|
|
type EffectiveWeapon,
|
|
} from './effective-weapons';
|
|
|
|
/** Keep persisted physical card shapes stable while validating their printed role. */
|
|
export function isPortableSnooper(card: Card | undefined): boolean {
|
|
return (
|
|
!!card && richeseCardDefinition(card)?.card.effect === 'portableSnooper'
|
|
);
|
|
}
|
|
export function isDefenseCard(card: Card): boolean {
|
|
return DEFENSE_KINDS.includes(card.kind) || isPortableSnooper(card);
|
|
}
|
|
export function isStoneBurner(card: Card | undefined): boolean {
|
|
return !!card && richeseCardDefinition(card)?.card.effect === 'stoneBurner';
|
|
}
|
|
export function isWeaponCard(card: Card): boolean {
|
|
return WEAPON_KINDS.includes(card.kind) || isStoneBurner(card);
|
|
}
|
|
|
|
export const WEAPON_KINDS = [
|
|
'projectile',
|
|
'poison',
|
|
'lasgun',
|
|
'worthless',
|
|
'poisonBlade',
|
|
'poisonTooth',
|
|
'artillery',
|
|
'weirdingWay',
|
|
'chemistry',
|
|
];
|
|
export const DEFENSE_KINDS = [
|
|
'shield',
|
|
'snooper',
|
|
'worthless',
|
|
'shieldSnooper',
|
|
'weirdingWay',
|
|
'chemistry',
|
|
];
|
|
export const VOICE_KINDS = [
|
|
'stoneBurner',
|
|
'poison',
|
|
'projectile',
|
|
'lasgun',
|
|
'shield',
|
|
'snooper',
|
|
'worthless',
|
|
'hero',
|
|
'poisonBlade',
|
|
'poisonTooth',
|
|
'artillery',
|
|
'shieldSnooper',
|
|
'weirdingWay',
|
|
'chemistry',
|
|
];
|
|
export const BATTLE_CARD_HELP: Partial<Record<Card['kind'], string>> = {
|
|
artillery:
|
|
'Kills both leaders unless each is protected by a shield. Surviving leaders add no battle strength, and no leader bounty is paid. Discard after use.',
|
|
poisonTooth:
|
|
'After plans are revealed, choose whether to activate. If activated, attacks both leaders; Chemistry as a defense protects, while Snoopers do not. Discard if used; a winner may retain an unused tooth.',
|
|
poisonBlade:
|
|
'A projectile and poison weapon. Both defenses are needed to protect the opposing leader.',
|
|
shieldSnooper:
|
|
'Both projectile and poison defense. This is a shield and triggers a lasgun explosion.',
|
|
weirdingWay:
|
|
'A projectile weapon by default. With another weapon or Worthless card in the weapon slot, play it as a projectile defense. It is not a shield and does not trigger a lasgun explosion.',
|
|
chemistry:
|
|
'A poison defense by default. With another defense or Worthless card in the defense slot, play it as a poison weapon. It has only the role selected for this battle.',
|
|
};
|
|
|
|
/** Roles refer to the selected slot; alternate roles need the other slot occupied. */
|
|
export function validBattleCardPair(weapon?: Card, defense?: Card) {
|
|
return (
|
|
(!weapon || isWeaponCard(weapon)) &&
|
|
(!defense || isDefenseCard(defense)) &&
|
|
(!weapon || weapon.id !== defense?.id) &&
|
|
(weapon?.kind !== 'chemistry' || !!defense) &&
|
|
(defense?.kind !== 'weirdingWay' || !!weapon)
|
|
);
|
|
}
|
|
export function weaponTypes(card?: Card): string[] {
|
|
if (!card) return [];
|
|
if (isStoneBurner(card)) return ['stoneBurner'];
|
|
if (card.kind === 'poisonBlade') return ['projectile', 'poison'];
|
|
if (card.kind === 'weirdingWay') return ['projectile'];
|
|
if (card.kind === 'chemistry' || card.kind === 'poisonTooth')
|
|
return ['poison'];
|
|
return [card.kind];
|
|
}
|
|
export function defenseTypes(card?: Card): string[] {
|
|
if (!card) return [];
|
|
if (isPortableSnooper(card)) return ['snooper'];
|
|
if (card.kind === 'shieldSnooper') return ['shield', 'snooper'];
|
|
if (card.kind === 'weirdingWay') return ['shield'];
|
|
if (card.kind === 'chemistry') return ['snooper'];
|
|
return [card.kind];
|
|
}
|
|
export function isShield(card?: Card) {
|
|
return card?.kind === 'shield' || card?.kind === 'shieldSnooper';
|
|
}
|
|
export function weaponKills(weapon?: Card, defense?: Card) {
|
|
return effectiveWeaponKills(
|
|
isStoneBurner(weapon) ? 'stoneBurner' : (weapon?.kind ?? null),
|
|
defense,
|
|
);
|
|
}
|
|
/** Resolve attack behavior without changing a physical card's identity or role. */
|
|
function effectiveWeaponKills(
|
|
kind: EffectiveWeapon['kind'],
|
|
defense?: Card,
|
|
extraSnooper = false,
|
|
) {
|
|
if (kind === 'artillery') return !isShield(defense);
|
|
if (kind === 'poisonTooth') return defense?.kind !== 'chemistry';
|
|
const attack =
|
|
kind === 'poisonBlade'
|
|
? ['projectile', 'poison']
|
|
: kind === 'weirdingWay'
|
|
? ['projectile']
|
|
: kind === 'chemistry'
|
|
? ['poison']
|
|
: [kind],
|
|
protect = defenseTypes(defense);
|
|
return (
|
|
attack.includes('lasgun') ||
|
|
(attack.includes('projectile') && !protect.includes('shield')) ||
|
|
(attack.includes('poison') && !protect.includes('snooper') && !extraSnooper)
|
|
);
|
|
}
|
|
/** Compulsion considers the card's default role, never forces an alternate role. */
|
|
export function defaultVoiceMatch(card: Card, kind: string) {
|
|
if (card.kind === kind) return true;
|
|
return (
|
|
isPortableSnooper(card) ||
|
|
['shield', 'snooper', 'shieldSnooper', 'chemistry'].includes(card.kind)
|
|
? defenseTypes(card)
|
|
: weaponTypes(card)
|
|
).includes(kind);
|
|
}
|
|
export function playedVoiceMatch(
|
|
card: Card | undefined,
|
|
slot: 'weapon' | 'defense' | 'leader',
|
|
kind: string,
|
|
) {
|
|
return (
|
|
!!card &&
|
|
(card.kind === kind ||
|
|
(slot === 'weapon'
|
|
? weaponTypes(card)
|
|
: slot === 'defense'
|
|
? defenseTypes(card)
|
|
: []
|
|
).includes(kind))
|
|
);
|
|
}
|
|
|
|
export function battleCardLabel(kind: string) {
|
|
return (
|
|
(
|
|
{
|
|
poisonTooth: 'Poison Tooth',
|
|
artillery: 'Artillery Strike',
|
|
stoneBurner: 'Stone Burner',
|
|
poisonBlade: 'Poison Blade',
|
|
shieldSnooper: 'Shield Snooper',
|
|
weirdingWay: 'Weirding Way',
|
|
chemistry: 'Chemistry',
|
|
hero: 'Cheap Hero',
|
|
shield: 'Projectile defense',
|
|
snooper: 'Poison defense',
|
|
projectile: 'Projectile weapon',
|
|
poison: 'Poison weapon',
|
|
lasgun: 'Lasgun',
|
|
worthless: 'Worthless card',
|
|
} as Record<string, string>
|
|
)[kind] ?? kind
|
|
);
|
|
}
|
|
|
|
/** Ordinary resolution only: traitors and lasgun explosions take precedence. */
|
|
export function battleCardEffects(
|
|
aw?: Card,
|
|
ad?: Card,
|
|
dw?: Card,
|
|
dd?: Card,
|
|
toothA = true,
|
|
toothD = true,
|
|
extraSnoopers: { attacker?: boolean; defender?: boolean } = {},
|
|
) {
|
|
const weapons = resolveBattleWeapons({
|
|
attacker: { weapon: aw, defense: ad },
|
|
defender: { weapon: dw, defense: dd },
|
|
});
|
|
if (weapons.error) throw new Error(weapons.error);
|
|
const a =
|
|
weapons.attacker.kind === 'poisonTooth' && !toothA
|
|
? null
|
|
: weapons.attacker.kind;
|
|
const d =
|
|
weapons.defender.kind === 'poisonTooth' && !toothD
|
|
? null
|
|
: weapons.defender.kind;
|
|
const selfAttack = (kind: EffectiveWeapon['kind']) =>
|
|
kind === 'artillery' || kind === 'poisonTooth';
|
|
const artillery = a === 'artillery' || d === 'artillery';
|
|
return {
|
|
attackerDead:
|
|
effectiveWeaponKills(d, ad, extraSnoopers.attacker) ||
|
|
(selfAttack(a) && effectiveWeaponKills(a, ad, extraSnoopers.attacker)),
|
|
defenderDead:
|
|
effectiveWeaponKills(a, dd, extraSnoopers.defender) ||
|
|
(selfAttack(d) && effectiveWeaponKills(d, dd, extraSnoopers.defender)),
|
|
stunned: artillery,
|
|
noBounty: artillery,
|
|
};
|
|
}
|
|
|
|
/** Explosion and ordinary attacks consume the same revealed weapon roles. */
|
|
export function battleWeaponsExplode(
|
|
aw?: Card,
|
|
ad?: Card,
|
|
dw?: Card,
|
|
dd?: Card,
|
|
) {
|
|
const weapons = resolveBattleWeapons({
|
|
attacker: { weapon: aw, defense: ad },
|
|
defender: { weapon: dw, defense: dd },
|
|
});
|
|
if (weapons.error) throw new Error(weapons.error);
|
|
return (
|
|
(weapons.attacker.kind === 'lasgun' ||
|
|
weapons.defender.kind === 'lasgun') &&
|
|
(isShield(ad) || isShield(dd))
|
|
);
|
|
}
|