Files
Dune/game/card-presentation.ts
T
Quintine c04cb93830 Connect the Recruits independent-card revival preview
The explicit development initializer now includes the complete three-card Ecaz Treachery variant before genuine Basic/Advanced faction setup. Recruits has owned play/discard controls, full inspection, a public current-rate table, shared authoritative revival quotes, all four AI profiles and persistent exact free-use ledgers. Existing CHOAM/Tleilaxu choices settle before returning forces. Inactive games retain their prior allowance arithmetic.

Clean activation before normal returns or after exactly recorded free returns is connected. Prior-paid/unknown use, later Fremen grants, pending repricing, same-turn recovered-card replay and additional optional modules stay gated. Native unlimited faction advantages remain unlimited. The independent seven-force cap after faction cancellation is explicitly documented as an inference from independent effects, not a direct combined FAQ. Reinforcements and Harass & Withdraw remain unfinished; public starts and publication stay gated.

Independent rules/privacy/persistence review passed. Review fixed auction alias double-counting after a physical card sale, malformed canonical cards, legacy zero-ledger activation, a seat-control validation bypass and an ordinary-start bypass. Focused tests cover readiness and turn expiry as well as authenticated restart, exact free/paid accounting, stale/duplicate requests, competing writes and malformed-save rejection. Types, lint, 4743 offline tests, build and 43 HTTP tests passed with unchanged source.

Eight fixed-seed genuine six-seat samples finish: basic/Easy: 1961 accepted, 0 Recruits plays, 53 JSON restores; basic/Medium: 711 accepted, 0 Recruits plays, 19 JSON restores; basic/Hard: 239 accepted, 0 Recruits plays, 6 JSON restores; basic/Brutal: 1367 accepted, 1 Recruits plays, 36 JSON restores; advanced/Easy: 1402 accepted, 0 Recruits plays, 37 JSON restores; advanced/Medium: 530 accepted, 0 Recruits plays, 14 JSON restores; advanced/Hard: 545 accepted, 1 Recruits plays, 14 JSON restores; advanced/Brutal: 1240 accepted, 1 Recruits plays, 33 JSON restores. Reports retain rejected candidates and earlier harness attempts. All 216 game-source hashes remain identical to the samples; a later presentation-test expectation update changes no game code. Actual card use, custody and periodic/terminal private views are checked; this is bounded playability evidence, not full variant acceptance or AI calibration. A separate conserved browser Revival fixture verifies the full inspector, physical play, public rates, four free returns and active/resolved refresh.

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

Verified source tree: 1f934f996268b35c8a20d0d617fa962aad878108496fa1a4a05323360757b0e3
2026-09-14 03:44:21 +10:00

161 lines
7.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { Card } from './cards';
import { BATTLE_CARD_HELP, battleCardLabel } from './battle-cards';
import { RULE_TOPICS, type RuleTopic } from './reference';
import { ecazTreacheryDefinition } from './ecaz-cards';
import { richeseCardDefinition } from './richese-cards';
import { printedCardCategory } from './card-category';
/** Presentation uses only a card the caller has already been authorized to see. */
export type VisibleCard = Readonly<
Pick<Card, 'id' | 'name' | 'kind' | 'effect'>
>;
export type CardPresentation = {
category: string;
role: 'weapon' | 'defense' | 'leader' | 'utility';
guidance: string;
/** Complete player-facing rules for a canonical component, separate from audit metadata. */
gameplay?: readonly string[];
/** A bounded component may be inspectable before its actions are implemented. */
availability?: string;
topics: readonly RuleTopic[];
};
/** UI eligibility only; exact identity avoids disabling unrelated special cards. */
export function richeseCardActionBlock(card: VisibleCard): string | null {
const definition = richeseCardDefinition(card);
if (definition?.card.effect === 'stoneBurner')
return 'Choose Stone Burner in your battle weapon slot, then choose its leader effect after both plans are revealed.';
if (definition?.card.effect === 'portableSnooper')
return 'Choose Portable Snooper as your battle defense, or use its late-defense panel after reveal before submitting your traitor decision.';
if (definition?.card.effect === 'residualPoison')
return 'Use the Residual Poison panel before either combatant commits a leader.';
if (definition?.card.effect === 'ornithopter')
return 'Use the Ornithopter movement controls with your selected force group.';
if (definition?.card.effect === 'nullentropyBox')
return 'Use the Nullentropy Box panel to pay for a private search.';
if (definition?.card.effect === 'juiceOfSapho')
return 'Use the Juice of Sapho panel to choose an available Once Around or movement order change.';
if (definition?.card.effect === 'distrans')
return 'Choose a recipient and card in the Distrans transfer panel.';
return definition && definition.card.effect !== 'karama'
? 'This Richese card’s effect is not implemented yet. You can inspect its rules.'
: null;
}
const BASIC_GUIDANCE: Partial<Record<Card['kind'], string>> = {
projectile:
'Play in the weapon slot of your battle plan. A projectile weapon kills an opposing leader who has no projectile defense.',
poison:
'Play in the weapon slot of your battle plan. A poison weapon kills an opposing leader who has no poison defense.',
lasgun:
'Play in the weapon slot. A lasgun kills the opposing leader. If either player uses a Shield or Shield Snooper, a lasgun explosion takes precedence over ordinary weapon effects; traitor resolution comes first.',
shield:
'Play in the defense slot to protect your leader from projectile weapons. A lasgun played against any shield causes an explosion unless traitor resolution overrides it.',
snooper:
'Play in the defense slot to protect your leader from ordinary poison weapons. A Snooper does not protect against an activated Poison Tooth.',
worthless:
'May occupy either the weapon or defense slot in a battle plan, but supplies no attack or protection. Some factions can spend Worthless cards for their own powers.',
hero: 'Use instead of a leader in your battle plan. A Cheap Hero or Heroine has zero leader strength and is discarded after use.',
};
const BATTLE_TOPIC: Partial<Record<Card['kind'], string>> = {
poisonTooth: 'card-poison-tooth',
artillery: 'card-artillery',
poisonBlade: 'ix-battle-cards',
shieldSnooper: 'ix-battle-cards',
weirdingWay: 'ix-battle-cards',
chemistry: 'ix-battle-cards',
hero: 'cheap-hero-traitor',
};
/** Canonical component guides and the internal reference supply original explanations.
* Audit metadata never enters this presentation or its rendered rules text.
*/
export function cardPresentation(card: VisibleCard): CardPresentation {
const richese = richeseCardDefinition(card);
if (richese)
return {
category: richese.printedType,
role:
richese.behavior.battleCategory === 'weapon'
? 'weapon'
: richese.behavior.battleCategory === 'poison-defense'
? 'defense'
: 'utility',
guidance: richese.summary,
gameplay: richese.gameplay,
availability:
richese.card.effect === 'juiceOfSapho'
? 'Richese effect integration and verification are incomplete. Supported controls cover Once Around first before bidding begins, Once Around last before your bid, and bounded movement order changes. Battle aggressor and other phase or auction modes remain unfinished; expansion starts remain disabled.'
: richese.card.effect === 'stoneBurner'
? 'Stone Burner has development battle controls. Combined allocation timing and Ix timing remain guarded; full expansion starts stay disabled.'
: 'Richese effect integration and verification are incomplete. Karama, Distrans, Nullentropy Box, Ornithopter, Residual Poison, Portable Snooper and Stone Burner have card handlers in development fixtures; full expansion starts remain disabled.',
topics: RULE_TOPICS.filter(
(topic) =>
topic.id ===
(richese.card.effect === 'juiceOfSapho'
? 'juice-of-sapho'
: richese.card.effect === 'stoneBurner'
? 'stone-burner'
: richese.card.effect === 'portableSnooper'
? 'portable-snooper'
: 'richese-cards'),
),
};
const ecaz = ecazTreacheryDefinition(card);
if (ecaz && ecaz.card.name === card.name)
return {
category: 'Special treachery',
role: 'utility',
guidance: ecaz.summary,
gameplay: ecaz.gameplay,
availability: ecaz.card.effect === 'recruits'
? 'Recruits has development controls during Revival. Earlier paid revivals, pending transactions, later free-rate changes and repeated use this turn remain guarded pending their rulings.'
: 'This battle effect is still being implemented.',
topics: RULE_TOPICS.filter((topic) => topic.id === 'card-recruits'),
};
const topicIds =
card.kind === 'special'
? [`card-${card.effect ?? ''}`]
: card.kind === 'worthless'
? [
'battle-cards',
'bg-charity-karama',
...(card.name === 'Trip to Gamont'
? ['choam-gamont']
: card.name === 'Jubba Cloak'
? ['choam-jubba']
: ['choam-worthless']),
]
: [
'battle-cards',
...(BATTLE_TOPIC[card.kind] ? [BATTLE_TOPIC[card.kind]!] : []),
];
const topics = topicIds
.map((id) => RULE_TOPICS.find((topic) => topic.id === id))
.filter((topic): topic is RuleTopic => !!topic);
const category = printedCardCategory(card);
const role =
category === 'hero'
? 'leader'
: category === 'special' || category === 'worthless'
? 'utility'
: category;
return {
category:
card.kind === 'special'
? 'Special treachery'
: battleCardLabel(card.kind),
role,
guidance:
(card.kind === 'special' && card.effect === 'ghola'
? 'Play at any time to return one eligible dead leader, or up to five forces, for free. Forces return to your reserves. Discard this card after use.'
: undefined) ??
BATTLE_CARD_HELP[card.kind] ??
BASIC_GUIDANCE[card.kind] ??
topics[0]?.summary ??
'Inspect the card’s available controls and the internal rules reference for its timing and permitted targets.',
topics,
};
}