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:
parent
72647a8268
commit
38fd46618e
|
|
@ -1,8 +1,8 @@
|
||||||
import type { CardEffect } from './cardEffect.csv';
|
import type { CardEffect } from './cardEffect.csv';
|
||||||
|
|
||||||
export type CardType = "item" | "status";
|
export type CardType = 'item' | 'status';
|
||||||
export type CardCostType = "energy" | "uses" | "none";
|
export type CardCostType = 'energy' | 'uses' | 'none';
|
||||||
export type CardTargetType = "player" | "enemy" | "enemies";
|
export type CardTargetType = 'player' | 'enemy' | 'enemies';
|
||||||
|
|
||||||
type CardTable = readonly {
|
type CardTable = readonly {
|
||||||
readonly id: string;
|
readonly id: string;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import type { Card } from './card.csv';
|
import type { Card } from './card.csv';
|
||||||
import type { Effect } from './effect.csv';
|
import type { Effect } from './effect.csv';
|
||||||
|
|
||||||
export type CardEffectTrigger = "onPlay" | "onDraw" | "onDiscard";
|
export type CardEffectTrigger = 'onPlay' | 'onDraw' | 'onDiscard';
|
||||||
export type CardEffectTarget = "user" | "eachTarget" | "eachEnemy" | "randomEnemy" | "player";
|
export type CardEffectTarget = 'user' | 'eachTarget' | 'eachEnemy' | 'randomEnemy' | 'player';
|
||||||
export type CardEffectList = [effect: Effect, stacks: number][];
|
export type CardEffectList = [effect: Effect, stacks: number][];
|
||||||
|
|
||||||
type CardEffectTable = readonly {
|
type CardEffectTable = readonly {
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
type EffectTable = readonly {
|
||||||
readonly id: string;
|
readonly id: string;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import type { Enemy } from './enemy.csv';
|
import type { Enemy } from './enemy.csv';
|
||||||
import type { Effect } from './effect.csv';
|
import type { Effect } from './effect.csv';
|
||||||
|
|
||||||
export type EncounterType = "minion" | "elite" | "event" | "shop" | "camp" | "curio";
|
export type EncounterType = 'minion' | 'elite' | 'event' | 'shop' | 'camp' | 'curio';
|
||||||
export type EnemyList = [data: Enemy, hp: number, effects: [effect: Effect, stacks: number][]][];
|
export type EnemyList = [data: Enemy, hp: int, effects: [effect: Effect, stacks: int][]][];
|
||||||
|
|
||||||
type EncounterTable = readonly {
|
type EncounterTable = readonly {
|
||||||
readonly id: string;
|
readonly id: string;
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import type { Enemy } from './enemy.csv';
|
import type { Enemy } from './enemy.csv';
|
||||||
import type { Effect } from './effect.csv';
|
import type { Effect } from './effect.csv';
|
||||||
|
|
||||||
export type IntentEffectTarget = "user" | "eachEnemy" | "randomEnemy" | "player";
|
export type IntentEffectTarget = 'user' | 'eachEnemy' | 'randomEnemy' | 'player';
|
||||||
export type IntentEffect = ["user" | "eachEnemy" | "randomEnemy" | "player", Effect, number];
|
export type IntentEffect = [IntentEffectTarget, Effect, number];
|
||||||
export type IntentEffectList = ["user" | "eachEnemy" | "randomEnemy" | "player", Effect, number][];
|
export type IntentEffectList = IntentEffect[];
|
||||||
|
|
||||||
type IntentTable = readonly {
|
type IntentTable = readonly {
|
||||||
readonly id: string;
|
readonly id: string;
|
||||||
|
|
|
||||||
|
|
@ -1,89 +1,23 @@
|
||||||
export type EffectData = {
|
import {
|
||||||
readonly id: string;
|
Card,
|
||||||
readonly name: string;
|
Effect,
|
||||||
readonly description: string;
|
Encounter,
|
||||||
readonly lifecycle: EffectLifecycle;
|
EncounterType,
|
||||||
};
|
Enemy,
|
||||||
export type EffectLifecycle =
|
Intent,
|
||||||
| "instant"
|
Item,
|
||||||
| "temporary"
|
} from "../data/desert";
|
||||||
| "lingering"
|
|
||||||
| "permanent"
|
|
||||||
| "posture"
|
|
||||||
| "item"
|
|
||||||
| "itemTemporary"
|
|
||||||
| "itemUntilPlay"
|
|
||||||
| "itemUntilDiscard"
|
|
||||||
| "itemPermanent";
|
|
||||||
|
|
||||||
export type EnemyData = {
|
export type CardData = Card;
|
||||||
readonly id: string;
|
export type ItemData = Item;
|
||||||
readonly name: string;
|
export type EffectData = Effect;
|
||||||
readonly intents: readonly IntentData[];
|
export type IntentData = Intent;
|
||||||
readonly description: string;
|
export type EnemyData = Enemy;
|
||||||
};
|
export type EncounterData<T extends EncounterType = EncounterType> =
|
||||||
|
Encounter & { type: T };
|
||||||
|
|
||||||
export type CardType = "item" | "status";
|
export {
|
||||||
export type CardCostType = "energy" | "uses" | "none";
|
CardTargetType,
|
||||||
export type CardTargetType = "single" | "none";
|
CardEffectTarget,
|
||||||
export type EffectTarget = "self" | "player" | "team";
|
IntentEffectTarget,
|
||||||
|
} from "../data/desert";
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue