203 lines
5.5 KiB
TypeScript
203 lines
5.5 KiB
TypeScript
import type { MAIN_STATS, ABILITIES, LEVELS, TRAINING_LEVELS, SPELL_TYPES, CATEGORIES, SPELL_ELEMENTS, ALIGNMENTS } from "#shared/character.util";
|
|
|
|
export type MainStat = typeof MAIN_STATS[number];
|
|
export type Ability = typeof ABILITIES[number];
|
|
export type Level = typeof LEVELS[number];
|
|
export type TrainingLevel = typeof TRAINING_LEVELS[number];
|
|
export type SpellType = typeof SPELL_TYPES[number];
|
|
export type Category = typeof CATEGORIES[number];
|
|
export type SpellElement = typeof SPELL_ELEMENTS[number];
|
|
export type Alignment = typeof ALIGNMENTS[number];
|
|
|
|
export type FeatureID = string;
|
|
export type TextID = string;
|
|
export type Resistance = string;
|
|
|
|
export type Dice = `${number}d${4 | 6 | 8 | 10 | 12 | 20}`;
|
|
|
|
export type Character = {
|
|
id: number;
|
|
|
|
name: string;
|
|
people?: string;
|
|
level: number;
|
|
aspect?: number;
|
|
notes?: string | null;
|
|
|
|
training: Record<MainStat, Partial<Record<TrainingLevel, number>>>;
|
|
leveling: Partial<Record<Level, number>>;
|
|
abilities: Partial<Record<Ability, number>>;
|
|
variables: CharacterVariables;
|
|
choices: Record<FeatureID, number[]>;
|
|
|
|
owner: number;
|
|
username?: string;
|
|
visibility: "private" | "public";
|
|
};
|
|
export type CharacterVariables = {
|
|
health: number;
|
|
mana: number;
|
|
exhaustion: number;
|
|
|
|
sickness: Array<{ id: string, state: number | true }>;
|
|
spells: string[]; //Spell ID
|
|
equipment: string[]; //Equipment ID
|
|
};
|
|
export type CharacterConfig = {
|
|
peoples: Record<string, RaceConfig>;
|
|
resistances: Record<Resistance, { name: string, statistic: MainStat }>;
|
|
training: Record<MainStat, Record<TrainingLevel, FeatureID[]>>;
|
|
abilities: Record<Ability, AbilityConfig>;
|
|
spells: SpellConfig[];
|
|
aspects: AspectConfig[];
|
|
features: Record<FeatureID, Feature>;
|
|
enchantments: Record<string, { name: string, effect: FeatureEffect[] }>; //TODO
|
|
items: Record<string, ItemConfig & { enchantments: string[] }>;
|
|
lists: Record<string, { id: string, name: string, [key: string]: any }[]>;
|
|
texts: Record<TextID, Localized>;
|
|
};
|
|
export type ItemConfig = { id: string, weight?: number, price?: number, power: number } & (ArmorConfig | WeaponConfig | WondrousConfig | MundaneConfig);
|
|
type ArmorConfig = {
|
|
category: 'armor';
|
|
name: string; //TODO -> TextID
|
|
description: TextID;
|
|
life: number;
|
|
absorb: number;
|
|
};
|
|
type WeaponConfig = {
|
|
category: 'armor';
|
|
name: string; //TODO -> TextID
|
|
description: TextID;
|
|
damage: Dice;
|
|
};
|
|
type WondrousConfig = {
|
|
category: 'armor';
|
|
name: string; //TODO -> TextID
|
|
description: TextID;
|
|
effect: FeatureEffect[];
|
|
};
|
|
type MundaneConfig = {
|
|
category: 'armor';
|
|
name: string; //TODO -> TextID
|
|
description: TextID;
|
|
};
|
|
export type SpellConfig = {
|
|
id: string;
|
|
name: string;
|
|
rank: 1 | 2 | 3 | 4;
|
|
type: SpellType;
|
|
cost: number;
|
|
speed: "action" | "reaction" | number;
|
|
elements: Array<SpellElement>;
|
|
effect: string;
|
|
concentration: boolean;
|
|
tags?: string[];
|
|
};
|
|
export type AbilityConfig = {
|
|
max: [MainStat, MainStat];
|
|
name: string;
|
|
description: string;
|
|
};
|
|
export type RaceConfig = {
|
|
id: string;
|
|
name: string;
|
|
description: string;
|
|
options: Record<Level, FeatureID[]>;
|
|
};
|
|
export type AspectConfig = {
|
|
name: string;
|
|
description: string;
|
|
stat: MainStat | 'special';
|
|
alignment: Alignment;
|
|
magic: boolean;
|
|
difficulty: number;
|
|
physic: { min: number, max: number };
|
|
mental: { min: number, max: number };
|
|
personality: { min: number, max: number };
|
|
options: FeatureEffect[];
|
|
};
|
|
|
|
export type FeatureEffect = {
|
|
id: FeatureID;
|
|
category: "value";
|
|
operation: "add" | "set";
|
|
property: string;
|
|
value: number | `modifier/${MainStat}` | false;
|
|
} | {
|
|
id: FeatureID;
|
|
category: "list";
|
|
list: "spells" | "sickness" | "action" | "reaction" | "freeaction" | "passive";
|
|
action: "add" | "remove";
|
|
item: string;
|
|
extra?: any;
|
|
};
|
|
export type FeatureItem = FeatureEffect | {
|
|
id: FeatureID;
|
|
category: "choice";
|
|
text: string;
|
|
settings?: { //If undefined, amount is 1 by default
|
|
amount: number;
|
|
exclusive: boolean; //Disallow to pick the same option twice
|
|
};
|
|
options: Array<FeatureEffect & { text: string }>;
|
|
}
|
|
export type Feature = {
|
|
id: FeatureID;
|
|
description: string;
|
|
effect: FeatureItem[];
|
|
};
|
|
|
|
export type CompiledCharacter = {
|
|
id: number;
|
|
owner?: number;
|
|
username?: string;
|
|
name: string;
|
|
health: number; //Max
|
|
mana: number; //Max
|
|
race: string;
|
|
spellslots: number; //Max
|
|
artslots: number; //Max
|
|
spellranks: Record<SpellType, 0 | 1 | 2 | 3>;
|
|
aspect: string; //ID
|
|
speed: number | false;
|
|
capacity: number | false;
|
|
initiative: number;
|
|
exhaust: number;
|
|
itempower: number;
|
|
|
|
action: number;
|
|
reaction: number;
|
|
|
|
variables: CharacterVariables,
|
|
|
|
defense: {
|
|
hardcap: number;
|
|
static: number;
|
|
activeparry: number;
|
|
activedodge: number;
|
|
passiveparry: number;
|
|
passivedodge: number;
|
|
};
|
|
|
|
mastery: {
|
|
strength: number;
|
|
dexterity: number;
|
|
shield: number;
|
|
armor: number;
|
|
multiattack: number;
|
|
magicpower: number;
|
|
magicspeed: number;
|
|
magicelement: number;
|
|
magicinstinct: number;
|
|
};
|
|
|
|
bonus: Record<string, number>; //Any special bonus goes here
|
|
resistance: Record<string, number>;
|
|
|
|
modifier: Record<MainStat, number>;
|
|
abilities: Partial<Record<Ability, number>>;
|
|
level: number;
|
|
lists: { [K in Extract<FeatureEffect, { category: "list" }>["list"]]?: string[] };
|
|
|
|
notes: string;
|
|
}; |