forked from WikiDeck/wikideck
[duel-cards] Match duel-core's contract (#72): template ids, description, maxTokens = fewer than N
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+619
-315
File diff suppressed because it is too large
Load Diff
@@ -48,6 +48,8 @@ export interface DuelCard {
|
|||||||
pageId: number;
|
pageId: number;
|
||||||
revisionId: number;
|
revisionId: number;
|
||||||
title: string;
|
title: string;
|
||||||
|
/** Wikidata short description, for log first mentions (omitted when absent). */
|
||||||
|
description?: string;
|
||||||
type: CardType;
|
type: CardType;
|
||||||
/** Template family within the type, e.g. 'conflict', 'election', 'organisation', 'pathology'. */
|
/** Template family within the type, e.g. 'conflict', 'election', 'organisation', 'pathology'. */
|
||||||
subtype: string | null;
|
subtype: string | null;
|
||||||
@@ -291,6 +293,7 @@ export function derive(chain: CardOnChain, profile: CardProfile, rules: DeriveRu
|
|||||||
rarity: rarityOf(chain.tokenId), deriveVersion: DERIVE_VERSION, typedBy: source,
|
rarity: rarityOf(chain.tokenId), deriveVersion: DERIVE_VERSION, typedBy: source,
|
||||||
basis: { pctAttention: p.attention, pctDepth: p.depth, pctReach: p.reach, fame, magnitude },
|
basis: { pctAttention: p.attention, pctDepth: p.depth, pctReach: p.reach, fame, magnitude },
|
||||||
};
|
};
|
||||||
|
if (profile.description) card.description = profile.description;
|
||||||
card.rulesText = rulesTextFor(card);
|
card.rulesText = rulesTextFor(card);
|
||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-2
@@ -19,8 +19,11 @@ export interface EffectSpec {
|
|||||||
toughness?: number;
|
toughness?: number;
|
||||||
duration?: 'turn' | 'permanent';
|
duration?: 'turn' | 'permanent';
|
||||||
token?: { name: string; power: number; toughness: number; portal: Portal };
|
token?: { name: string; power: number; toughness: number; portal: Portal };
|
||||||
condition?: { maxPower?: number; samePortal?: boolean; connected?: boolean; maxTokens?: number; whileAttacking?: boolean };
|
/** 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[];
|
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])[];
|
||||||
@@ -67,7 +70,23 @@ export function subtypeFor(type: CardType, profile: Pick<CardProfile, 'instanceO
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The effect list for a card (T1–T12). Figures and Locations have none beyond keywords and stats. */
|
/** The effect list for a card (T1–T12). Figures and Locations have none beyond keywords and stats. */
|
||||||
|
/** DUEL_DESIGN §5 template id by type and subtype. */
|
||||||
|
export function templateFor(type: CardType, subtype: string | null): string | null {
|
||||||
|
switch (type) {
|
||||||
|
case 'Figure': return 'T1';
|
||||||
|
case 'Location': return 'T2';
|
||||||
|
case 'Event': return ({ conflict: 'T3', disaster: 'T4', election: 'T5', sport: 'T6' } as Record<string, string>)[subtype ?? ''] ?? 'T7';
|
||||||
|
case 'Institution': return subtype === 'organisation' ? 'T8' : subtype === 'work' ? 'T9' : 'T10';
|
||||||
|
case 'Doctrine': return subtype === 'pathology' ? 'T12' : 'T11';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function effectsFor(type: CardType, subtype: string | null, cost: number): EffectSpec[] {
|
export function effectsFor(type: CardType, subtype: string | null, cost: number): EffectSpec[] {
|
||||||
|
const template = templateFor(type, subtype);
|
||||||
|
return baseEffects(type, subtype, cost).map(e => (template ? { ...e, template } : e));
|
||||||
|
}
|
||||||
|
|
||||||
|
function baseEffects(type: CardType, subtype: string | null, cost: number): EffectSpec[] {
|
||||||
const k = Math.ceil(cost / 2);
|
const k = Math.ceil(cost / 2);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'Event':
|
case 'Event':
|
||||||
@@ -87,7 +106,7 @@ export function effectsFor(type: CardType, subtype: string | null, cost: number)
|
|||||||
case 'organisation': {
|
case 'organisation': {
|
||||||
const token = { name: 'Staff Member', power: 1, toughness: 1, portal: 'Neutral' as const };
|
const token = { name: 'Staff Member', power: 1, toughness: 1, portal: 'Neutral' as const };
|
||||||
return cost >= 4
|
return cost >= 4
|
||||||
? [{ trigger: 'startOfTurn', op: 'createToken', amount: 1, token, condition: { maxTokens: 2 } }]
|
? [{ trigger: 'startOfTurn', op: 'createToken', amount: 1, token, condition: { maxTokens: 3 } }]
|
||||||
: [{ trigger: 'onEnter', op: 'createToken', amount: 1, token }];
|
: [{ trigger: 'onEnter', op: 'createToken', amount: 1, token }];
|
||||||
}
|
}
|
||||||
case 'work': return [
|
case 'work': return [
|
||||||
|
|||||||
+2
-2
@@ -41,7 +41,7 @@ function staticText(e: EffectSpec): string {
|
|||||||
if (c.connected) who = 'Figures you control that are Connected to this';
|
if (c.connected) who = 'Figures you control that are Connected to this';
|
||||||
if (c.samePortal) who = 'Other Figures you control of its Portal';
|
if (c.samePortal) who = 'Other Figures you control of its Portal';
|
||||||
if (e.grant?.length && !e.power && !e.toughness) {
|
if (e.grant?.length && !e.power && !e.toughness) {
|
||||||
return `${who} have ${keywordsAsText(e.grant)}${c.whileAttacking ? ' while attacking' : ''}.`;
|
return `${who} have ${keywordsAsText(e.grant)}.`;
|
||||||
}
|
}
|
||||||
return `${who} get ${pt(e.power, e.toughness)}.`;
|
return `${who} get ${pt(e.power, e.toughness)}.`;
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ export function effectText(effects: readonly EffectSpec[]): string[] {
|
|||||||
case 'onDestroyed': lines.push(`When this is destroyed, ${actionText(e)}.`); break;
|
case 'onDestroyed': lines.push(`When this is destroyed, ${actionText(e)}.`); break;
|
||||||
case 'startOfTurn': {
|
case 'startOfTurn': {
|
||||||
const max = e.condition?.maxTokens;
|
const max = e.condition?.maxTokens;
|
||||||
const cond = max !== undefined ? `, if you control fewer than ${max + 1} tokens` : '';
|
const cond = max !== undefined ? `, if you control fewer than ${max} tokens` : '';
|
||||||
lines.push(`At the start of your turn${cond}, ${actionText(e)}.`);
|
lines.push(`At the start of your turn${cond}, ${actionText(e)}.`);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user