Add logic tree computation and item enchantment.

This commit is contained in:
2026-01-26 00:05:05 +01:00
parent 777443471c
commit e9a892076d
6 changed files with 325 additions and 288 deletions

View File

@@ -14,6 +14,7 @@ export type DamageType = typeof DAMAGE_TYPES[number];
export type WeaponType = typeof WEAPON_TYPES[number];
export type FeatureID = string;
export type FeatureEffectID = string;
export type i18nID = string;
export type RecursiveKeyOf<TObj extends object> = {
@@ -57,10 +58,6 @@ export type CharacterVariables = {
money: number;
};
export enum TreeFlag {
AUTOMATIC = 1 << 0,
REPEATING = 1 << 1,
};
export type TreeLeaf = {
id: FeatureID;
to?: FeatureID | Array<FeatureID> | Record<string, FeatureID>;
@@ -68,14 +65,14 @@ export type TreeLeaf = {
};
export type TreeStructure = {
name: string;
starts: FeatureID;
start: FeatureID | Array<FeatureID> | Record<string, FeatureID>;
nodes: Record<FeatureID, TreeLeaf>;
};
type CommonState = {
capacity?: number;
powercost?: number;
};
type ArmorState = { loss: number, health?: number, absorb?: { flat?: number, percent?: number } };
type ArmorState = { loss: number, health?: number, absorb: { flat?: number, percent?: number } };
type WeaponState = { attack?: number | string, hit?: number };
type WondrousState = { };
type MundaneState = { };
@@ -86,6 +83,7 @@ type ItemState = {
charges?: number;
equipped?: boolean;
state?: (ArmorState | WeaponState | WondrousState | MundaneState) & CommonState;
buffer?: Record<string, PropertySum>
};
export type CharacterConfig = {
peoples: Record<string, RaceConfig>;
@@ -196,34 +194,35 @@ export type AspectConfig = {
};
export type FeatureValue = {
id: FeatureID;
id: FeatureEffectID;
category: "value";
operation: "add" | "set" | "min";
property: RecursiveKeyOf<CompiledCharacter> | 'spec' | 'ability' | 'training';
value: number | `modifier/${MainStat}` | false;
}
export type FeatureEquipment = {
id: FeatureID;
id: FeatureEffectID;
category: "value";
operation: "add" | "set" | "min";
property: `item/${RecursiveKeyOf<ArmorState & WeaponState & WondrousState & MundaneState & CommonState>}`;
value: number | `modifier/${MainStat}` | false;
};
export type FeatureList = {
id: FeatureID;
id: FeatureEffectID;
category: "list";
list: "spells" | "sickness" | "action" | "reaction" | "freeaction" | "passive" | "mastery";
action: "add" | "remove";
item: string;
};
export type FeatureTree = {
id: FeatureID;
id: FeatureEffectID;
category: "tree";
tree: string;
option?: string;
priority?: number;
};
export type FeatureChoice = {
id: FeatureID;
id: FeatureEffectID;
category: "choice";
text: string; //TODO -> TextID
settings?: { //If undefined, amount is 1 by default
@@ -294,7 +293,7 @@ export type CompiledCharacter = {
modifier: Record<MainStat, number>;
abilities: Partial<Record<Ability, number>>;
level: number;
lists: { [K in FeatureList['list']]?: string[] }; //string => ListItem ID
lists: { [K in Exclude<FeatureList['list'], 'mastery'>]: string[] }; //string => ListItem ID
notes: { public: string, private: string };
};