refactor(slay-the-spire-like): extract types in desert data schemas

This commit is contained in:
hypercross 2026-04-22 16:00:15 +08:00
parent bb4528cd27
commit 888b7b822d
3 changed files with 16 additions and 6 deletions

View File

@ -1,13 +1,17 @@
import type { CardEffect } from './cardEffect.csv'; import type { CardEffect } from './cardEffect.csv';
type CardType = "item" | "status";
type CardCostType = "energy" | "uses" | "none";
type CardTargetType = "player" | "enemy" | "enemies";
type CardTable = readonly { type CardTable = readonly {
readonly id: string; readonly id: string;
readonly name: string; readonly name: string;
readonly desc: string; readonly desc: string;
readonly type: "item" | "status"; readonly type: CardType;
readonly costType: "energy" | "uses" | "none"; readonly costType: CardCostType;
readonly costCount: number; readonly costCount: number;
readonly targetType: "single" | "none"; readonly targetType: CardTargetType;
readonly effects: CardEffect[]; readonly effects: CardEffect[];
}[]; }[];

View File

@ -1,8 +1,11 @@
type EffectLifecycle = "instant" | "temporary" | "lingering" | "permanent" | "posture" | "item" | "itemTemporary" | "itemUntilPlay" | "itemUntilDiscard" | "itemPermanent";
type EffectTable = readonly { type EffectTable = readonly {
readonly id: string; readonly id: string;
readonly name: string; readonly name: string;
readonly description: string; readonly description: string;
readonly lifecycle: "instant" | "temporary" | "lingering" | "permanent" | "posture" | "item" | "itemTemporary" | "itemUntilPlay" | "itemUntilDiscard" | "itemPermanent"; readonly lifecycle: EffectLifecycle;
readonly emoji: string;
}[]; }[];
export type Effect = EffectTable[number]; export type Effect = EffectTable[number];

View File

@ -1,12 +1,15 @@
import type { Enemy } from './enemy.csv'; import type { Enemy } from './enemy.csv';
import type { Effect } from './effect.csv'; import type { Effect } from './effect.csv';
type EncounterType = "minion" | "elite" | "event" | "shop" | "camp" | "curio";
type EnemyList = [data: Enemy, hp: number, effects: [effect: Effect, stacks: number][]][];
type EncounterTable = readonly { type EncounterTable = readonly {
readonly id: string; readonly id: string;
readonly type: "minion" | "elite" | "event" | "shop" | "camp" | "curio"; readonly type: EncounterType;
readonly name: string; readonly name: string;
readonly description: string; readonly description: string;
readonly enemies: [data: Enemy, hp: number, effects: [effect: Effect, stacks: number][]][]; readonly enemies: EnemyList;
readonly dialogue: string; readonly dialogue: string;
}[]; }[];