This commit is contained in:
Forrest 2026-09-29 14:46:56 -04:00
parent 5d771eed1b
commit 5368464042
28 changed files with 887 additions and 187 deletions

View file

@ -19,6 +19,8 @@ export interface CardDef {
/** Card text; flavor text for Avatars. */
text: string;
ability?: { name: string; cost: number; text: string };
/** Card set: 1 is the base game, 2 the expansion. Rows without a Set column are set 1. */
set: number;
}
export interface CardPool {
@ -41,13 +43,18 @@ export const DEFAULT_CARDS_CSV = fileURLToPath(
const num = (s: string | undefined): number => (s ? Number(s) : 0);
/** Loads the Cider deck CSV. Reference cards (Turn Sequence) are skipped. */
export function loadCards(path = DEFAULT_CARDS_CSV): CardPool {
/**
* Loads the Cider deck CSV. Reference cards (Turn Sequence) are skipped. By default only set 1 (the
* base game) is loaded; `sets` picks others, or 'all'. Set 2 cards have no scripts yet.
*/
export function loadCards(path = DEFAULT_CARDS_CSV, sets: number[] | 'all' = [1]): CardPool {
const all: CardDef[] = [];
const byName = new Map<string, CardDef>();
for (const row of parseCsvObjects(readFileSync(path, 'utf8'))) {
const kind = KIND_BY_TEMPLATE[row['Front Template']];
if (!kind) continue;
const set = row['Set'] ? Number(row['Set']) : 1;
if (sets !== 'all' && !sets.includes(set)) continue;
const card: CardDef = {
name: row['Name'],
kind,
@ -57,6 +64,7 @@ export function loadCards(path = DEFAULT_CARDS_CSV): CardPool {
slots: num(row['Expansion Slots']),
type: row['Type'],
text: row['Description'],
set,
};
if (row['Ability Name']) {
card.ability = {