Fix dynamic character sheet loading.

This commit is contained in:
Clément Pons
2026-03-09 17:27:18 +01:00
parent 974989abd3
commit 3bafc14255
10 changed files with 329 additions and 14505 deletions

View File

@@ -92,8 +92,10 @@ onMounted(async () => {
tree.value.appendChild(load);
const content = dom('div', { class: 'flex flex-row justify-start items-center gap-4 p-2' }, [
tooltip(button(icon('ph:cloud-arrow-down', { height: 20, width: 20 }), pull, 'p-1'), 'Actualiser', 'top'),
tooltip(button(icon('ph:cloud-arrow-up', { height: 20, width: 20 }), push, 'p-1'), 'Enregistrer', 'top'),
tooltip(button(icon('ph:cloud-arrow-down', { height: 16, width: 16 }), pull, 'p-1'), 'Actualiser', 'top'),
tooltip(button(icon('ph:cloud-arrow-up', { height: 16, width: 16 }), push, 'p-1'), 'Enregistrer', 'top'),
tooltip(button(icon('radix-icons:reset', { height: 16, width: 16 }), () => editor?.undo(), 'p-1'), 'Annuler', 'top'),
tooltip(button(icon('radix-icons:reset', { height: 16, width: 16, hFlip: true }), () => editor?.redo(), 'p-1'), 'Rétablir', 'top'),
])
tree.value.insertBefore(content, load);
@@ -105,6 +107,11 @@ onMounted(async () => {
}
});
useShortcuts({
"Meta-Z": () => editor?.undo(),
"Meta-Y": () => editor?.redo(),
});
onBeforeUnmount(() => {
editor?.unmount();
});

View File

@@ -129,7 +129,7 @@ type CommonItemConfig = {
powercost?: number; //Optionnal
charge?: number //Max amount of charges
enchantments?: string[]; //Enchantment ID
effects?: Array<FeatureValue | FeatureEquipment | FeatureList>;
effects?: Array<FeatureValue | FeatureState | FeatureEquipment | FeatureList>;
equippable: boolean;
consummable: boolean;
craft?: { mineral: number, natural: number, processed: number, magical: number };
@@ -168,15 +168,6 @@ export type SpellConfig = {
range: 'personnal' | number;
tags?: string[];
};
export type ArtConfig = {
id: string;
name: string; //TODO -> TextID
rank: 1 | 2 | 3;
type: "arts";
difficulty: number;
description: string; //TODO -> TextID
tags?: string[];
};
export type RaceConfig = {
id: string;
name: string; //TODO -> TextID
@@ -204,6 +195,12 @@ export type FeatureValue = {
property: RecursiveKeyOf<CompiledCharacter> | 'spec' | 'ability' | 'training';
value: number | `modifier/${MainStat}` | false;
}
export type FeatureState = {
id: FeatureEffectID;
category: "state";
property: RecursiveKeyOf<CompiledCharacter>;
value: string;
}
export type FeatureEquipment = {
id: FeatureEffectID;
category: "value";
@@ -235,7 +232,7 @@ export type FeatureChoice = {
};
options: Array<{ text: string, effects: Array<FeatureValue | FeatureList | FeatureTree> }>; //TODO -> TextID
};
export type FeatureItem = FeatureValue | FeatureList | FeatureChoice | FeatureTree;
export type FeatureItem = FeatureValue | FeatureState | FeatureList | FeatureChoice | FeatureTree;
export type Feature = {
id: FeatureID;
description: string; //TODO -> TextID
@@ -252,7 +249,7 @@ export type CompiledCharacter = {
race: string;
spellslots: number; //Max
artslots: number; //Max
spellranks: Record<SpellType | 'arts', 0 | 1 | 2 | 3>;
spellranks: Record<SpellType, 0 | 1 | 2 | 3>;
aspect: {
id: string,
amount: number;
@@ -290,6 +287,7 @@ export type CompiledCharacter = {
};
weapon: Partial<Record<WeaponType, number>>;
resistance: Partial<Record<Resistance, number>>; //Bonus à l'attaque
damage: Partial<DamageType, 'resistance' | 'immunity' | 'vulnerability'>;
}; //Any special bonus goes here
craft: { level: number, bonus: number };