refactor(samples): export desert data types

Export type definitions from desert CSV declaration files and
update the content module to use these exported types instead of
generic system types.
This commit is contained in:
hypercross 2026-04-22 16:48:54 +08:00
parent dbbbba14e2
commit 72647a8268
8 changed files with 40 additions and 35 deletions

View File

@ -1,8 +1,8 @@
import type { CardEffect } from './cardEffect.csv';
type CardType = "item" | "status";
type CardCostType = "energy" | "uses" | "none";
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,9 +1,9 @@
import type { Card } from './card.csv';
import type { Effect } from './effect.csv';
type CardEffectTrigger = "onPlay" | "onDraw" | "onDiscard";
type CardEffectTarget = "user" | "eachTarget" | "eachEnemy" | "randomEnemy" | "player";
type CardEffectList = [effect: Effect, stacks: number][];
export type CardEffectTrigger = "onPlay" | "onDraw" | "onDiscard";
export type CardEffectTarget = "user" | "eachTarget" | "eachEnemy" | "randomEnemy" | "player";
export type CardEffectList = [effect: Effect, stacks: number][];
type CardEffectTable = readonly {
readonly id: string;

View File

@ -1,4 +1,4 @@
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';
type EncounterType = "minion" | "elite" | "event" | "shop" | "camp" | "curio";
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: number, effects: [effect: Effect, stacks: number][]][];
type EncounterTable = readonly {
readonly id: string;

View File

@ -1,5 +1,13 @@
import getItems, { Item } from "./item.csv";
export type * from "./card.csv";
export type * from "./cardEffect.csv";
export type * from "./effect.csv";
export type * from "./encounter.csv";
export type * from "./enemy.csv";
export type * from "./intent.csv";
export type * from "./item.csv";
export { default as getCards } from "./card.csv";
export { default as getEffects } from "./effect.csv";
export { default as getEncounters } from "./encounter.csv";

View File

@ -7,9 +7,11 @@
# effects: effects executed when this intent is active
# type IntentEffectTarget = 'user' | 'eachEnemy' | 'randomEnemy' | 'player'
# type IntentEffect = [IntentEffectTarget;@effect;number]
# type IntentEffectList = IntentEffect[]
id,enemy,initialIntent,nextIntents,brokenIntent,effects
string,@enemy,boolean,@intent[],@intent[],[IntentEffectTarget;@effect;number][]
string,@enemy,boolean,@intent[],@intent[],IntentEffectList
仙人掌怪-boost,仙人掌怪,true,仙人掌怪-boost;仙人掌怪-defend,,[user;spike;1];[user;defend;4]
仙人掌怪-defend,仙人掌怪,false,仙人掌怪-attack,,[user;defend;8]
仙人掌怪-attack,仙人掌怪,false,仙人掌怪-boost,,[player;attack;5]

Can't render this file because it has a wrong number of fields in line 11.

View File

@ -1,16 +1,17 @@
import type { Enemy } from "./enemy.csv";
import type { Effect } from "./effect.csv";
import type { Enemy } from './enemy.csv';
import type { Effect } from './effect.csv';
type IntentEffectTarget = "user" | "eachEnemy" | "randomEnemy" | "player";
type IntentEffectList = [IntentEffectTarget, Effect, number][];
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][];
type IntentTable = readonly {
readonly id: string;
readonly enemy: Enemy;
readonly initialIntent: boolean;
readonly nextIntents: Intent[];
readonly brokenIntent: Intent[];
readonly effects: IntentEffectList;
readonly id: string;
readonly enemy: Enemy;
readonly initialIntent: boolean;
readonly nextIntents: Intent[];
readonly brokenIntent: Intent[];
readonly effects: IntentEffectList;
}[];
export type Intent = IntentTable[number];

View File

@ -1,22 +1,16 @@
import { LoadResult as YarnDialogues } from "yarn-spinner-loader";
import {
CardData,
EffectData,
EncounterData,
EnemyData,
IntentData,
ItemData,
} from "../system/types";
import { Triggers } from "../system/combat/triggers";
import type * as desert from "./desert";
export type ContentModule = {
getCards: () => CardData[];
getEffects: () => EffectData[];
getEncounters: () => EncounterData[];
getEnemies: () => EnemyData[];
getIntents: () => IntentData[];
getItems: () => ItemData[];
getStartingItems: () => ItemData[];
getCards: () => desert.Card[];
getEffects: () => desert.Effect[];
getEncounters: () => desert.Encounter[];
getEnemies: () => desert.Enemy[];
getIntents: () => desert.Intent[];
getItems: () => desert.Item[];
getStartingItems: () => desert.Item[];
dialogues: YarnDialogues;
addTriggers: (triggers: Triggers) => void;