forked from WikiDeck/wikideck
shared/duel/classify.ts: Q-id anchors -> P31 label regex (^human$) -> P279 -> categories -> description -> Doctrine. shared/duel/derive.ts: pure derive(chain, profile) -> DuelCard: fame cost 1-6, P+T budget per cost, DUEL_DESIGN §4 keywords (<=2, Figures only, taxed), Portals, Connected keys and tiers, flavour. shared/duel/effects.ts + text.ts: T1-T12 templates as EffectSpec data, MTG-register rules text. shared/duel/sample.ts + docs/game/duel-card-sample.json: 236-card DuelCard fixture. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
39 lines
1.7 KiB
TypeScript
39 lines
1.7 KiB
TypeScript
/**
|
|
* Fixture: docs/game/card-sample.json (236 real random cards) → DuelCard[], for sim-balance, the UI
|
|
* and tests. The sample has no on-chain extract, so flavour falls back to the description, and its
|
|
* tokenIds are synthetic (the pageId as 64 hex digits). Owner: duel-cards.
|
|
*/
|
|
import type { CardProfile } from './classify.ts';
|
|
import { derive, DERIVE_RULES, type CardOnChain, type DeriveRules, type DuelCard } from './derive.ts';
|
|
|
|
/** The fields of a card-sample.json card that derivation reads. */
|
|
export interface SampleCard {
|
|
pageId: number; title: string; description: string | null; wikidataId: string | null; revisionId: number;
|
|
pageBytes: number; languageCount: number; categories: string[];
|
|
stats: { attention: number | null; depth: number; reach: number };
|
|
instanceOf: { id: string; label: string }[];
|
|
extract?: string;
|
|
}
|
|
|
|
export function sampleTokenId(pageId: number): string {
|
|
return pageId.toString(16).padStart(64, '0');
|
|
}
|
|
|
|
export function sampleInputs(card: SampleCard): { chain: CardOnChain; profile: CardProfile } {
|
|
return {
|
|
chain: {
|
|
tokenId: sampleTokenId(card.pageId),
|
|
article: { pageId: card.pageId, title: card.title, extract: card.extract ?? '', revisionId: card.revisionId },
|
|
statsSnapshot: { pageBytes: card.pageBytes, languageCount: card.languageCount, stats: card.stats },
|
|
},
|
|
profile: {
|
|
wikidataId: card.wikidataId, description: card.description, categories: card.categories,
|
|
instanceOf: card.instanceOf, fetchedRevisionId: card.revisionId,
|
|
},
|
|
};
|
|
}
|
|
|
|
export function deriveSample(cards: readonly SampleCard[], rules: DeriveRules = DERIVE_RULES): DuelCard[] {
|
|
return cards.map(card => { const { chain, profile } = sampleInputs(card); return derive(chain, profile, rules); });
|
|
}
|