Impoved FloatingUI components and create a PickableFeature class

This commit is contained in:
Clément Pons
2025-08-13 17:39:58 +02:00
parent 4e5ea504ea
commit 72982a4ea9
10 changed files with 545 additions and 185 deletions

27
types/character.d.ts vendored
View File

@@ -8,7 +8,7 @@ export type SpellType = typeof SPELL_TYPES[number];
export type Category = typeof CATEGORIES[number];
export type SpellElement = typeof SPELL_ELEMENTS[number];
export type DoubleIndex<T extends number | string> = [T, number];
export type FeatureID = string;
export type Alignment = { loyalty: 'loyal' | 'neutral' | 'chaotic', kindness: 'good' | 'neutral' | 'evil' };
export type Character = {
@@ -34,17 +34,21 @@ export type Character = {
username?: string;
visibility: "private" | "public";
};
export type CharacterValues = {
export type CharacterVariables = {
health: number;
mana: number;
sickness: Array<{ id: string, progress: number | true }>;
equipment: Array<string>;
};
export type CharacterConfig = {
peoples: RaceConfig[],
training: Record<MainStat, Record<TrainingLevel, string[]>>;
training: Record<MainStat, Record<TrainingLevel, FeatureID[]>>;
abilities: Record<Ability, AbilityConfig>;
spells: SpellConfig[];
aspects: AspectConfig[];
features: Record<string, Feature>;
features: Record<FeatureID, Feature>;
lists: Record<string, { id: string, name: string, [key: string]: any }[]>;
};
export type SpellConfig = {
id: string;
@@ -65,7 +69,7 @@ export type AbilityConfig = {
export type RaceConfig = {
name: string;
description: string;
options: Record<Level, string[]>;
options: Record<Level, FeatureID[]>;
};
export type AspectConfig = {
name: string;
@@ -81,22 +85,23 @@ export type AspectConfig = {
};
export type FeatureEffect = {
id: string;
id: FeatureID;
category: "value";
operation: "add" | "set";
property: string;
value: number | `modifier/${MainStat}` | false;
} | {
id: string;
id: FeatureID;
category: "list";
list: "spells" | "action" | "reaction" | "freeaction" | "passive";
list: "spells" | "sickness" | "action" | "reaction" | "freeaction" | "passive";
action: "add" | "remove";
item: string;
extra?: any;
};
export type FeatureItem = FeatureEffect | {
id: string;
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
@@ -104,7 +109,7 @@ export type FeatureItem = FeatureEffect | {
options: Array<FeatureEffect & { text: string }>;
}
export type Feature = {
id: string;
id: FeatureID;
description: string;
effect: FeatureItem[];
};
@@ -125,7 +130,7 @@ export type CompiledCharacter = {
capacity: number | false;
initiative: number;
values: CharacterValues,
variables: CharacterVariables,
defense: {
hardcap: number;