refactor(slay-the-spire-like): use data definitions in system types

Remove redundant type definitions in `system/types.ts` and instead
import them from the generated CSV declaration files. Also update
declaration files to use single quotes for consistency with project
style rules.
This commit is contained in:
hypercross 2026-04-22 19:26:58 +08:00
parent 72647a8268
commit 38fd46618e
6 changed files with 32 additions and 98 deletions

View File

@ -1,8 +1,8 @@
import type { CardEffect } from './cardEffect.csv';
export type CardType = "item" | "status";
export type CardCostType = "energy" | "uses" | "none";
export type CardTargetType = "player" | "enemy" | "enemies";
export type CardType = 'item' | 'status';
export type CardCostType = 'energy' | 'uses' | 'none';
export type CardTargetType = 'player' | 'enemy' | 'enemies';
type CardTable = readonly {
readonly id: string;

View File

@ -1,8 +1,8 @@
import type { Card } from './card.csv';
import type { Effect } from './effect.csv';
export type CardEffectTrigger = "onPlay" | "onDraw" | "onDiscard";
export type CardEffectTarget = "user" | "eachTarget" | "eachEnemy" | "randomEnemy" | "player";
export type CardEffectTrigger = 'onPlay' | 'onDraw' | 'onDiscard';
export type CardEffectTarget = 'user' | 'eachTarget' | 'eachEnemy' | 'randomEnemy' | 'player';
export type CardEffectList = [effect: Effect, stacks: number][];
type CardEffectTable = readonly {

View File

@ -1,4 +1,4 @@
export type EffectLifecycle = "instant" | "temporary" | "lingering" | "permanent" | "posture" | "item" | "itemTemporary" | "itemUntilPlay" | "itemUntilDiscard" | "itemPermanent";
export type EffectLifecycle = 'instant' | 'temporary' | 'lingering' | 'permanent' | 'posture' | 'item' | 'itemTemporary' | 'itemUntilPlay' | 'itemUntilDiscard' | 'itemPermanent';
type EffectTable = readonly {
readonly id: string;

View File

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

View File

@ -1,9 +1,9 @@
import type { Enemy } from './enemy.csv';
import type { Effect } from './effect.csv';
export type IntentEffectTarget = "user" | "eachEnemy" | "randomEnemy" | "player";
export type IntentEffect = ["user" | "eachEnemy" | "randomEnemy" | "player", Effect, number];
export type IntentEffectList = ["user" | "eachEnemy" | "randomEnemy" | "player", Effect, number][];
export type IntentEffectTarget = 'user' | 'eachEnemy' | 'randomEnemy' | 'player';
export type IntentEffect = [IntentEffectTarget, Effect, number];
export type IntentEffectList = IntentEffect[];
type IntentTable = readonly {
readonly id: string;

View File

@ -1,89 +1,23 @@
export type EffectData = {
readonly id: string;
readonly name: string;
readonly description: string;
readonly lifecycle: EffectLifecycle;
};
export type EffectLifecycle =
| "instant"
| "temporary"
| "lingering"
| "permanent"
| "posture"
| "item"
| "itemTemporary"
| "itemUntilPlay"
| "itemUntilDiscard"
| "itemPermanent";
import {
Card,
Effect,
Encounter,
EncounterType,
Enemy,
Intent,
Item,
} from "../data/desert";
export type EnemyData = {
readonly id: string;
readonly name: string;
readonly intents: readonly IntentData[];
readonly description: string;
};
export type CardData = Card;
export type ItemData = Item;
export type EffectData = Effect;
export type IntentData = Intent;
export type EnemyData = Enemy;
export type EncounterData<T extends EncounterType = EncounterType> =
Encounter & { type: T };
export type CardType = "item" | "status";
export type CardCostType = "energy" | "uses" | "none";
export type CardTargetType = "single" | "none";
export type EffectTarget = "self" | "player" | "team";
export type CardEffectTrigger = "onPlay" | "onDraw" | "onDiscard";
export type CardEffectTarget = "self" | "target" | "all" | "random";
export type CardEffect = {
readonly id: string;
readonly trigger: CardEffectTrigger;
readonly target: CardEffectTarget;
readonly effects: readonly [EffectData, number][];
};
export type CardData = {
readonly id: string;
readonly name: string;
readonly desc: string;
readonly type: CardType;
readonly costType: CardCostType;
readonly costCount: number;
readonly targetType: CardTargetType;
readonly effects: readonly CardEffect[];
};
export type EncounterType =
| "minion"
| "elite"
| "event"
| "shop"
| "camp"
| "curio";
export type EncounterData<T extends EncounterType = EncounterType> = {
readonly id: string;
readonly type: T;
readonly name: string;
readonly description: string;
readonly enemies: readonly [
data: EnemyData,
hp: number,
effects: [EffectData, stacks: number][],
][];
readonly dialogue: string;
};
export type IntentData = {
readonly id: string;
readonly enemy: EnemyData;
readonly initialIntent: boolean;
readonly nextIntents: readonly IntentData[];
readonly brokenIntent: readonly IntentData[];
readonly effects: readonly [EffectTarget, EffectData, number][];
};
export type ItemData = {
readonly id: string;
readonly type: string;
readonly name: string;
readonly shape: string;
readonly card: CardData;
readonly price: number;
readonly description: string;
};
export {
CardTargetType,
CardEffectTarget,
IntentEffectTarget,
} from "../data/desert";