[duel-cards] Use duel-core's types.ts: DuelCard/ConnectKeys extend the contract, EffectSpec/Keyword/Portal/CardType re-exported; Trending reminder; text for drain/destroy/bounce/tap; 'adopted Figure'

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 22:53:35 -05:00
co-authored by Claude Opus 5.5
parent cd08c0f600
commit 85efb929be
4 changed files with 21 additions and 29 deletions
+3 -2
View File
@@ -6,8 +6,9 @@
* Owner: duel-cards. * Owner: duel-cards.
*/ */
export type CardType = 'Figure' | 'Location' | 'Event' | 'Institution' | 'Doctrine'; import type { CardType } from './types.ts';
export const CARD_TYPES: readonly CardType[] = ['Figure', 'Location', 'Event', 'Institution', 'Doctrine']; export type { CardType } from './types.ts';
export { CARD_TYPES } from './types.ts';
export interface WikidataClass { id: string; label: string } export interface WikidataClass { id: string; label: string }
+10 -6
View File
@@ -18,10 +18,10 @@ export type { EffectSpec } from './effects.ts';
export const DERIVE_VERSION = 'duel-derive-1'; export const DERIVE_VERSION = 'duel-derive-1';
export type Portal = 'Arts' | 'Earth' | 'History' | 'Science' | 'Society' | 'Neutral'; import type { ConnectKeys as CoreConnectKeys, DuelCard as CoreDuelCard, Keyword, Portal } from './types.ts';
export const PORTALS: readonly Portal[] = ['Arts', 'Earth', 'History', 'Science', 'Society', 'Neutral']; export type { Keyword, Portal } from './types.ts';
export type Keyword = 'Protected' | 'Featured' | 'Translated' | 'Legacy' | 'Stub' | 'Well-sourced' | 'Multilingual' | 'Local'; export { PORTALS } from './types.ts';
export type Rarity = 'Common' | 'Rare' | 'Epic' | 'Legendary'; export type Rarity = NonNullable<CoreDuelCard['rarity']>;
/** What derive() reads from the chain: a minted block's article and stats snapshot. */ /** What derive() reads from the chain: a minted block's article and stats snapshot. */
export interface CardOnChain { export interface CardOnChain {
@@ -30,7 +30,8 @@ export interface CardOnChain {
statsSnapshot: Pick<MintStatsSnapshot, 'pageBytes' | 'languageCount' | 'stats'>; statsSnapshot: Pick<MintStatsSnapshot, 'pageBytes' | 'languageCount' | 'stats'>;
} }
export interface ConnectKeys { /** duel-core's ConnectKeys, with `cites` always present. */
export interface ConnectKeys extends CoreConnectKeys {
/** P17/P27 values, or normalised country names from text when Wikidata has none. */ /** P17/P27 values, or normalised country names from text when Wikidata has none. */
countries: string[]; countries: string[];
centuries: number[]; centuries: number[];
@@ -43,7 +44,8 @@ export interface ConnectKeys {
cites: string[]; cites: string[];
} }
export interface DuelCard { /** duel-core's DuelCard (types.ts), with every field derive() always sets made required, plus audit fields. */
export interface DuelCard extends CoreDuelCard {
cardId: string; cardId: string;
pageId: number; pageId: number;
revisionId: number; revisionId: number;
@@ -235,6 +237,8 @@ export function triggeredKeywords(chain: CardOnChain, profile: CardProfile, p: P
Translated: p.reach >= rules.translatedPct && p.reach < rules.multilingualPct, Translated: p.reach >= rules.translatedPct && p.reach < rules.multilingualPct,
Stub: cats.some(c => c.toLowerCase().includes('stubs')) || chain.statsSnapshot.pageBytes < rules.stubBytes, Stub: cats.some(c => c.toLowerCase().includes('stubs')) || chain.statsSnapshot.pageBytes < rules.stubBytes,
Local: chain.statsSnapshot.stats.reach === 0, Local: chain.statsSnapshot.stats.reach === 0,
// Granted by Trending mode from frozen live data, never by derivation.
Trending: false,
}; };
return rules.keywordOrder.filter(k => on[k]); return rules.keywordOrder.filter(k => on[k]);
} }
+2 -20
View File
@@ -4,27 +4,9 @@
* Owner: duel-cards. * Owner: duel-cards.
*/ */
import type { CardProfile, CardType } from './classify.ts'; import type { CardProfile, CardType } from './classify.ts';
import type { Keyword, Portal } from './derive.ts'; import type { EffectSpec } from './types.ts';
export type EffectTrigger = 'onPlay' | 'onEnter' | 'startOfTurn' | 'onDestroyed' | 'static' | 'onCombatDamageToPlayer'; export type { EffectOp, EffectSpec, EffectTrigger, TargetSpec as EffectTarget } from './types.ts';
export type EffectOp = 'damage' | 'damageEach' | 'createToken' | 'pump' | 'fight' | 'draw' | 'attach' | 'gainLife';
export type EffectTarget = 'figure' | 'figureOrLocation' | 'ownFigure' | 'opponentFigure' | 'each' | 'self' | 'attached' | 'ownFigures';
export interface EffectSpec {
trigger: EffectTrigger;
op: EffectOp;
target?: EffectTarget;
amount?: number;
power?: number;
toughness?: number;
duration?: 'turn' | 'permanent';
token?: { name: string; power: number; toughness: number; portal: Portal };
/** maxTokens: createToken only if the controller controls fewer than this many tokens (duel-core types.ts). */
condition?: { maxPower?: number; samePortal?: boolean; connected?: boolean; maxTokens?: number };
grant?: Keyword[];
/** Template id (DUEL_DESIGN §5, T3–T12) for rules text and log wording. */
template?: string;
}
type Subtypes = readonly (readonly [string, RegExp])[]; type Subtypes = readonly (readonly [string, RegExp])[];
+6 -1
View File
@@ -17,6 +17,7 @@ export const KEYWORD_REMINDER: Readonly<Record<Keyword, string>> = {
'Well-sourced': 'Prevent the first 1 damage that would be dealt to this each turn.', 'Well-sourced': 'Prevent the first 1 damage that would be dealt to this each turn.',
Stub: 'At the start of your turn, put a +1/+1 counter on this, to a maximum of 2.', Stub: 'At the start of your turn, put a +1/+1 counter on this, to a maximum of 2.',
Local: 'Gets +1/+1 while you control a Compatriot Location.', Local: 'Gets +1/+1 while you control a Compatriot Location.',
Trending: 'Can attack the turn it enters. Gets +1/+0.',
}; };
const NUMBER_WORDS = ['zero', 'one', 'two', 'three', 'four', 'five', 'six']; const NUMBER_WORDS = ['zero', 'one', 'two', 'three', 'four', 'five', 'six'];
@@ -27,7 +28,7 @@ const pt = (p = 0, t = 0) => `${signed(p)}/${signed(t)}`;
const TARGET_NOUN: Readonly<Record<string, string>> = { const TARGET_NOUN: Readonly<Record<string, string>> = {
figure: 'target Figure', figureOrLocation: 'target Figure or Location', ownFigure: 'target Figure you control', figure: 'target Figure', figureOrLocation: 'target Figure or Location', ownFigure: 'target Figure you control',
opponentFigure: 'target Figure you don\'t control', each: 'each Figure and each Location', self: 'this', opponentFigure: 'target Figure you don\'t control', each: 'each Figure and each Location', self: 'this',
attached: 'enchanted Figure', ownFigures: 'Figures you control', attached: 'adopted Figure', ownFigures: 'Figures you control',
}; };
function keywordsAsText(keywords: readonly Keyword[]): string { function keywordsAsText(keywords: readonly Keyword[]): string {
@@ -64,6 +65,10 @@ function actionText(e: EffectSpec): string {
case 'draw': return e.amount === 1 ? 'draw a card' : `draw ${word(e.amount ?? 1)} cards`; case 'draw': return e.amount === 1 ? 'draw a card' : `draw ${word(e.amount ?? 1)} cards`;
case 'gainLife': return `you gain ${e.amount} Notability`; case 'gainLife': return `you gain ${e.amount} Notability`;
case 'attach': return ''; case 'attach': return '';
case 'drain': return `each opponent loses ${e.amount} Notability and you gain ${e.amount} Notability`;
case 'destroy': return `destroy ${TARGET_NOUN[e.target ?? 'figure'] ?? 'target permanent'}`;
case 'bounce': return `return ${TARGET_NOUN[e.target ?? 'figure'] ?? 'target permanent'} to its owner's hand`;
case 'tap': return `tap ${TARGET_NOUN[e.target ?? 'figure'] ?? 'target permanent'}`;
} }
} }