refactor(slay-the-spire-like): update data export pattern
Convert static data exports to getter functions and update the ContentModule type to reflect these changes.
This commit is contained in:
parent
6577897a42
commit
b264cea305
|
|
@ -1,19 +1,17 @@
|
|||
import getCards from "./card.csv";
|
||||
import getEffects from "./effect.csv";
|
||||
import getEncounters from "./encounter.csv";
|
||||
import getEnemies from "./enemy.csv";
|
||||
import getIntents from "./intent.csv";
|
||||
import getItems, { Item } from "./item.csv";
|
||||
|
||||
export { default as getCards } from "./card.csv";
|
||||
export { default as getEffects } from "./effect.csv";
|
||||
export { default as getEncounters } from "./encounter.csv";
|
||||
export { default as getEnemies } from "./enemy.csv";
|
||||
export { default as getIntents } from "./intent.csv";
|
||||
export { default as getItems } from "./item.csv";
|
||||
export { default as dialogues } from "./dialogues/dialogues.yarnproject";
|
||||
export { addTriggers } from "./triggers";
|
||||
|
||||
export const cards = getCards();
|
||||
export const effects = getEffects();
|
||||
export const encounters = getEncounters();
|
||||
export const enemies = getEnemies();
|
||||
export const intents = getIntents();
|
||||
export const items = getItems();
|
||||
|
||||
export const startingItems: Item[] = (
|
||||
["剑", "盾", "水袋", "绷带"] as string[]
|
||||
).map((key) => items.find((item) => item.name === key) as Item);
|
||||
const itemSet = ["剑", "盾", "水袋", "绷带"] as string[];
|
||||
export function getStartingItems(): Item[] {
|
||||
return itemSet.map(function (name): Item {
|
||||
return getItems().find((item: Item) => item.name === name) as Item;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,13 +10,14 @@ import {
|
|||
import { Triggers } from "../system/combat/triggers";
|
||||
|
||||
export type ContentModule = Partial<{
|
||||
cards: CardData[];
|
||||
effects: EffectData[];
|
||||
encounters: EncounterData[];
|
||||
enemies: EnemyData[];
|
||||
intents: IntentData[];
|
||||
items: ItemData[];
|
||||
getCards: CardData[];
|
||||
getEffects: EffectData[];
|
||||
getEncounters: EncounterData[];
|
||||
getEnemies: EnemyData[];
|
||||
getIntents: IntentData[];
|
||||
getItems: ItemData[];
|
||||
getStartingItems: ItemData[];
|
||||
|
||||
dialogues: YarnDialogues;
|
||||
addTriggers: (triggers: Triggers) => void;
|
||||
startingItems: ItemData[];
|
||||
}>;
|
||||
|
|
|
|||
Loading…
Reference in New Issue