refactor: types
This commit is contained in:
parent
3f3490fad8
commit
3dc566c2fd
|
|
@ -0,0 +1,17 @@
|
||||||
|
import type { Effect } from './effect.csv';
|
||||||
|
|
||||||
|
type CardTable = readonly {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
readonly desc: string;
|
||||||
|
readonly type: "item" | "status";
|
||||||
|
readonly costType: "energy" | "uses" | "none";
|
||||||
|
readonly costCount: number;
|
||||||
|
readonly targetType: "single" | "none";
|
||||||
|
readonly effects: readonly ["onPlay" | "onDraw" | "onDiscard", "self" | "target" | "all" | "random", Effect, number];
|
||||||
|
}[];
|
||||||
|
|
||||||
|
export type Card = CardTable[number];
|
||||||
|
|
||||||
|
declare function getData(): CardTable;
|
||||||
|
export default getData;
|
||||||
|
|
@ -41,14 +41,14 @@ crossbow, 十字弩连击, 对同一目标打出其他十字弩, instant
|
||||||
defendNext, 下回合防御, 下回合开始时获得防御, temporary
|
defendNext, 下回合防御, 下回合开始时获得防御, temporary
|
||||||
damageReduce, 减伤, 本回合受到的伤害减少X, temporary
|
damageReduce, 减伤, 本回合受到的伤害减少X, temporary
|
||||||
removeWound, 移除伤口, 从牌堆或弃牌堆移除X张伤口, instant
|
removeWound, 移除伤口, 从牌堆或弃牌堆移除X张伤口, instant
|
||||||
attackBuff, 攻击增益, 周围物品的攻击+X, itemUntilPlayed
|
attackBuff, 攻击增益, 周围物品的攻击+X, itemUntilPlay
|
||||||
defendBuff, 防御增益, 周围物品的防御+X, itemUntilPlayed
|
defendBuff, 防御增益, 周围物品的防御+X, itemUntilPlay
|
||||||
gainEnergy, 获得能量, 获得X点能量, instant
|
gainEnergy, 获得能量, 获得X点能量, instant
|
||||||
energyNext, 下回合获能量, 下回合开始时获得X点能量, temporary
|
energyNext, 下回合获能量, 下回合开始时获得X点能量, temporary
|
||||||
drawNext, 下回合抓牌, 下回合开始时抓X张牌, temporary
|
drawNext, 下回合抓牌, 下回合开始时抓X张牌, temporary
|
||||||
defendBuffUntilPlay, 防御增益直到打出, 周围物品的牌防御+X直到打出, itemUntilPlayed
|
defendBuffUntilPlay, 防御增益直到打出, 周围物品的牌防御+X直到打出, itemUntilPlay
|
||||||
drawChoice, 选择抓牌, 从牌堆周围物品的牌中选择一张加入手牌, instant
|
drawChoice, 选择抓牌, 从牌堆周围物品的牌中选择一张加入手牌, instant
|
||||||
burnForEnergy, 消耗获能量, 打出周围物品的牌时消耗并获得X能量, itemUntilPlayed
|
burnForEnergy, 消耗获能量, 打出周围物品的牌时消耗并获得X能量, itemUntilPlay
|
||||||
attackBuffUntilPlay, 攻击增益直到打出, 周围物品的牌攻击+X直到打出, itemUntilPlayed
|
attackBuffUntilPlay, 攻击增益直到打出, 周围物品的牌攻击+X直到打出, itemUntilPlay
|
||||||
transformRandom, 随机变牌, 选择一张牌随机变为周围物品的牌, instant
|
transformRandom, 随机变牌, 选择一张牌随机变为周围物品的牌, instant
|
||||||
expose, 暴露, 受到的伤害+1/每层, temporary
|
expose, 暴露, 受到的伤害+1/每层, temporary
|
||||||
|
|
|
||||||
|
Can't render this file because it has a wrong number of fields in line 18.
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
type EffectTable = readonly {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
readonly description: string;
|
||||||
|
readonly lifecycle: "instant" | "temporary" | "lingering" | "permanent" | "posture" | "card" | "cardDraw" | "cardHand" | "item" | "itemTemporary" | "itemUntilPlay" | "itemUntilDiscard" | "itemPermanent";
|
||||||
|
}[];
|
||||||
|
|
||||||
|
export type Effect = EffectTable[number];
|
||||||
|
|
||||||
|
declare function getData(): EffectTable;
|
||||||
|
export default getData;
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
import type { Enemy } from './enemy.csv';
|
||||||
|
import type { Effect } from './effect.csv';
|
||||||
|
|
||||||
|
type EncounterTable = readonly {
|
||||||
|
readonly id: string;
|
||||||
|
readonly type: "minion" | "elite" | "event" | "shop" | "camp" | "curio";
|
||||||
|
readonly name: string;
|
||||||
|
readonly description: string;
|
||||||
|
readonly enemies: readonly [Enemy, number, readonly [readonly effect: Effect, readonly stacks: number]];
|
||||||
|
readonly dialogue: string;
|
||||||
|
}[];
|
||||||
|
|
||||||
|
export type Encounter = EncounterTable[number];
|
||||||
|
|
||||||
|
declare function getData(): EncounterTable;
|
||||||
|
export default getData;
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
type EnemyTable = readonly {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
readonly description: string;
|
||||||
|
}[];
|
||||||
|
|
||||||
|
export type Enemy = EnemyTable[number];
|
||||||
|
|
||||||
|
declare function getData(): EnemyTable;
|
||||||
|
export default getData;
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
import type { Enemy } from './enemy.csv';
|
||||||
|
import type { Effect } from './effect.csv';
|
||||||
|
|
||||||
|
type IntentTable = readonly {
|
||||||
|
readonly enemy: Enemy;
|
||||||
|
readonly intentId: string;
|
||||||
|
readonly initialIntent: boolean;
|
||||||
|
readonly nextIntents: readonly string[];
|
||||||
|
readonly brokenIntent: readonly string[];
|
||||||
|
readonly initBuffs: readonly [Effect, readonly stacks: number];
|
||||||
|
readonly effects: readonly ["self" | "player" | "team", Effect, number];
|
||||||
|
}[];
|
||||||
|
|
||||||
|
export type Intent = IntentTable[number];
|
||||||
|
|
||||||
|
declare function getData(): IntentTable;
|
||||||
|
export default getData;
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
import type { Card } from './card.csv';
|
||||||
|
|
||||||
|
type ItemTable = readonly {
|
||||||
|
readonly id: string;
|
||||||
|
readonly type: string;
|
||||||
|
readonly name: string;
|
||||||
|
readonly shape: string;
|
||||||
|
readonly card: Card;
|
||||||
|
readonly price: number;
|
||||||
|
readonly description: string;
|
||||||
|
}[];
|
||||||
|
|
||||||
|
export type Item = ItemTable[number];
|
||||||
|
|
||||||
|
declare function getData(): ItemTable;
|
||||||
|
export default getData;
|
||||||
|
|
@ -1,147 +0,0 @@
|
||||||
// Data
|
|
||||||
export { heroItemFighter1Data, encounterDesertData, enemyDesertData, effectDesertData, cardDesertData } from './data';
|
|
||||||
export { default as encounterDesertCsv } from './data/encounterDesert.csv';
|
|
||||||
export type { EncounterDesert, CardDesert } from './data';
|
|
||||||
|
|
||||||
// Deck
|
|
||||||
export type { GameCard, GameCardMeta, PlayerDeck, DeckRegions } from './deck';
|
|
||||||
export {
|
|
||||||
generateDeckFromInventory,
|
|
||||||
createStatusCard,
|
|
||||||
createDeckRegions,
|
|
||||||
createPlayerDeck,
|
|
||||||
generateCardId,
|
|
||||||
} from './deck';
|
|
||||||
|
|
||||||
// Grid Inventory
|
|
||||||
export type { CellCoordinate, CellKey, GridInventory, InventoryItem, MutationResult, PlacementResult } from './grid-inventory';
|
|
||||||
export {
|
|
||||||
createGridInventory,
|
|
||||||
flipItem,
|
|
||||||
getAdjacentItems,
|
|
||||||
getItemAtCell,
|
|
||||||
getOccupiedCellSet,
|
|
||||||
moveItem,
|
|
||||||
placeItem,
|
|
||||||
removeItem,
|
|
||||||
rotateItem,
|
|
||||||
validatePlacement,
|
|
||||||
} from './grid-inventory';
|
|
||||||
|
|
||||||
// Map
|
|
||||||
export { MapNodeType, MapLayerType } from './map';
|
|
||||||
export type { MapNode, MapLayer, PointCrawlMap } from './map';
|
|
||||||
export { generatePointCrawlMap, getNode, getChildren, getParents, hasPath, findAllPaths } from './map';
|
|
||||||
|
|
||||||
// Progress Manager
|
|
||||||
export type {
|
|
||||||
EncounterResult,
|
|
||||||
EncounterState,
|
|
||||||
GameItem,
|
|
||||||
GameItemMeta,
|
|
||||||
PlayerState,
|
|
||||||
RunMutationResult,
|
|
||||||
RunState,
|
|
||||||
} from './progress';
|
|
||||||
export {
|
|
||||||
addGold,
|
|
||||||
addItemFromCsv,
|
|
||||||
canMoveTo,
|
|
||||||
createRunState,
|
|
||||||
damagePlayer,
|
|
||||||
getReachableChildren,
|
|
||||||
getCurrentNode,
|
|
||||||
getUnresolvedChildren,
|
|
||||||
healPlayer,
|
|
||||||
isAtEndNode,
|
|
||||||
isAtStartNode,
|
|
||||||
isEncounterResolved,
|
|
||||||
moveToNode,
|
|
||||||
removeItem as removeItemFromRun,
|
|
||||||
resolveEncounter,
|
|
||||||
setMaxHp,
|
|
||||||
spendGold,
|
|
||||||
} from './progress';
|
|
||||||
|
|
||||||
// Utils - Parse Shape
|
|
||||||
export type { ParsedShape } from './utils/parse-shape';
|
|
||||||
export { parseShapeString } from './utils/parse-shape';
|
|
||||||
|
|
||||||
// Utils - Shape Collision
|
|
||||||
export type { Point2D, Transform2D } from './utils/shape-collision';
|
|
||||||
export {
|
|
||||||
IDENTITY_TRANSFORM,
|
|
||||||
getOccupiedCells,
|
|
||||||
transformPoint,
|
|
||||||
transformShape,
|
|
||||||
checkCollision,
|
|
||||||
checkBoardCollision,
|
|
||||||
checkBounds,
|
|
||||||
validatePlacement as validateShapePlacement,
|
|
||||||
rotateTransform,
|
|
||||||
flipXTransform,
|
|
||||||
flipYTransform,
|
|
||||||
} from './utils/shape-collision';
|
|
||||||
|
|
||||||
// Combat
|
|
||||||
export type {
|
|
||||||
BuffTable,
|
|
||||||
CombatEffectEntry,
|
|
||||||
CombatEntity,
|
|
||||||
CombatGameContext,
|
|
||||||
CombatPhase,
|
|
||||||
CombatResult,
|
|
||||||
CombatState,
|
|
||||||
EffectTarget,
|
|
||||||
EffectTiming,
|
|
||||||
EnemyState,
|
|
||||||
ItemBuff,
|
|
||||||
LootEntry,
|
|
||||||
PlayerCombatState,
|
|
||||||
} from './combat';
|
|
||||||
|
|
||||||
export type {
|
|
||||||
TriggerContext,
|
|
||||||
BuffTriggerBehavior,
|
|
||||||
CombatTriggerRegistry,
|
|
||||||
TriggerEvent,
|
|
||||||
} from './combat';
|
|
||||||
|
|
||||||
export {
|
|
||||||
createCombatState,
|
|
||||||
createEnemyInstance,
|
|
||||||
createPlayerCombatState,
|
|
||||||
drawCardsToHand,
|
|
||||||
addFatigueCards,
|
|
||||||
discardHand,
|
|
||||||
discardCard,
|
|
||||||
exhaustCard,
|
|
||||||
getEnemyCurrentIntent,
|
|
||||||
advanceEnemyIntent,
|
|
||||||
getEffectTiming,
|
|
||||||
getEffectData,
|
|
||||||
INITIAL_HAND_SIZE,
|
|
||||||
DEFAULT_MAX_ENERGY,
|
|
||||||
FATIGUE_CARDS_PER_SHUFFLE,
|
|
||||||
applyDamage,
|
|
||||||
applyDefend,
|
|
||||||
applyBuff,
|
|
||||||
removeBuff,
|
|
||||||
updateBuffs,
|
|
||||||
resolveEffect,
|
|
||||||
resolveCardEffects,
|
|
||||||
getModifiedAttackDamage,
|
|
||||||
getModifiedDefendAmount,
|
|
||||||
canPlayCard,
|
|
||||||
playCard,
|
|
||||||
areAllEnemiesDead,
|
|
||||||
isPlayerDead,
|
|
||||||
createCombatTriggerRegistry,
|
|
||||||
dispatchTrigger,
|
|
||||||
dispatchAttackedTrigger,
|
|
||||||
dispatchDamageTrigger,
|
|
||||||
dispatchOutgoingDamageTrigger,
|
|
||||||
dispatchIncomingDamageTrigger,
|
|
||||||
dispatchShuffleTrigger,
|
|
||||||
runCombat,
|
|
||||||
} from './combat';
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
export type EffectData = {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
readonly description: string;
|
||||||
|
readonly lifecycle: EffectLifecycle;
|
||||||
|
};
|
||||||
|
export type EffectLifecycle = "instant" | "temporary" | "lingering" | "permanent" | "posture" | "card" | "cardDraw" | "cardHand" | "item" | "itemTemporary" | "itemUntilPlay" | "itemUntilDiscard" | "itemPermanent";
|
||||||
|
|
||||||
|
export type EnemyData = {
|
||||||
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
|
readonly description: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type CardType = "item" | "status";
|
||||||
|
export type CardCostType = "energy" | "uses" | "none";
|
||||||
|
export type CardTargetType = "single" | "none";
|
||||||
|
export type EffectTarget = "self" | "player" | "team";
|
||||||
|
|
||||||
|
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 [CardEffectTrigger, CardEffectTarget, EffectData, number][];
|
||||||
|
};
|
||||||
|
export type CardEffectTrigger = "onPlay" | "onDraw" | "onDiscard";
|
||||||
|
export type CardEffectTarget = "self" | "target" | "all" | "random"
|
||||||
|
|
||||||
|
export type EncounterType = "minion" | "elite" | "event" | "shop" | "camp" | "curio";
|
||||||
|
export type EncounterData = {
|
||||||
|
readonly id: string;
|
||||||
|
readonly type: EncounterType;
|
||||||
|
readonly name: string;
|
||||||
|
readonly description: string;
|
||||||
|
readonly enemies: readonly [EnemyData, number, readonly [effect: EffectData, stacks: number]];
|
||||||
|
readonly dialogue: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type IntentData = {
|
||||||
|
readonly enemy: EnemyData;
|
||||||
|
readonly intentId: string;
|
||||||
|
readonly initialIntent: boolean;
|
||||||
|
readonly nextIntents: readonly string[];
|
||||||
|
readonly brokenIntent: readonly string[];
|
||||||
|
readonly initBuffs: readonly [EffectData, stacks: number];
|
||||||
|
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