diff --git a/shared/duel/classify.ts b/shared/duel/classify.ts index 2f59bb7..52fce1f 100644 --- a/shared/duel/classify.ts +++ b/shared/duel/classify.ts @@ -6,8 +6,9 @@ * Owner: duel-cards. */ -export type CardType = 'Figure' | 'Location' | 'Event' | 'Institution' | 'Doctrine'; -export const CARD_TYPES: readonly CardType[] = ['Figure', 'Location', 'Event', 'Institution', 'Doctrine']; +import type { CardType } from './types.ts'; +export type { CardType } from './types.ts'; +export { CARD_TYPES } from './types.ts'; export interface WikidataClass { id: string; label: string } diff --git a/shared/duel/derive.ts b/shared/duel/derive.ts index 85956f1..2044f63 100644 --- a/shared/duel/derive.ts +++ b/shared/duel/derive.ts @@ -18,10 +18,10 @@ export type { EffectSpec } from './effects.ts'; export const DERIVE_VERSION = 'duel-derive-1'; -export type Portal = 'Arts' | 'Earth' | 'History' | 'Science' | 'Society' | 'Neutral'; -export const PORTALS: readonly Portal[] = ['Arts', 'Earth', 'History', 'Science', 'Society', 'Neutral']; -export type Keyword = 'Protected' | 'Featured' | 'Translated' | 'Legacy' | 'Stub' | 'Well-sourced' | 'Multilingual' | 'Local'; -export type Rarity = 'Common' | 'Rare' | 'Epic' | 'Legendary'; +import type { ConnectKeys as CoreConnectKeys, DuelCard as CoreDuelCard, Keyword, Portal } from './types.ts'; +export type { Keyword, Portal } from './types.ts'; +export { PORTALS } from './types.ts'; +export type Rarity = NonNullable; /** What derive() reads from the chain: a minted block's article and stats snapshot. */ export interface CardOnChain { @@ -30,7 +30,8 @@ export interface CardOnChain { statsSnapshot: Pick; } -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. */ countries: string[]; centuries: number[]; @@ -43,7 +44,8 @@ export interface ConnectKeys { 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; pageId: 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, Stub: cats.some(c => c.toLowerCase().includes('stubs')) || chain.statsSnapshot.pageBytes < rules.stubBytes, 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]); } diff --git a/shared/duel/effects.ts b/shared/duel/effects.ts index c433f6d..4f4f5be 100644 --- a/shared/duel/effects.ts +++ b/shared/duel/effects.ts @@ -4,27 +4,9 @@ * Owner: duel-cards. */ 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 = '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; -} +export type { EffectOp, EffectSpec, EffectTrigger, TargetSpec as EffectTarget } from './types.ts'; type Subtypes = readonly (readonly [string, RegExp])[]; diff --git a/shared/duel/text.ts b/shared/duel/text.ts index 49bc556..ce44397 100644 --- a/shared/duel/text.ts +++ b/shared/duel/text.ts @@ -17,6 +17,7 @@ export const KEYWORD_REMINDER: Readonly> = { '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.', 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']; @@ -27,7 +28,7 @@ const pt = (p = 0, t = 0) => `${signed(p)}/${signed(t)}`; const TARGET_NOUN: Readonly> = { 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', - attached: 'enchanted Figure', ownFigures: 'Figures you control', + attached: 'adopted Figure', ownFigures: 'Figures you control', }; 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 'gainLife': return `you gain ${e.amount} Notability`; 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'}`; } }