You've already forked obsidian-visualiser
Fix dynamic character sheet loading.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import type { Ability, ArmorConfig, AspectConfig, CharacterConfig, CommonItemConfig, DamageType, Feature, FeatureChoice, FeatureEquipment, FeatureItem, FeatureList, FeatureTree, FeatureValue, ItemConfig, Level, MainStat, MundaneConfig, RaceConfig, Resistance, SpellConfig, TrainingLevel, WeaponConfig, WeaponType, WondrousConfig } from "~/types/character";
|
||||
import type { Ability, ArmorConfig, AspectConfig, CharacterConfig, CommonItemConfig, DamageType, Feature, FeatureChoice, FeatureEquipment, FeatureItem, FeatureList, FeatureState, FeatureTree, FeatureValue, ItemConfig, Level, MainStat, MundaneConfig, RaceConfig, Resistance, SpellConfig, TrainingLevel, WeaponConfig, WeaponType, WondrousConfig } from "~/types/character";
|
||||
import { div, dom, icon, span, text, type NodeChildren } from "#shared/dom";
|
||||
import { MarkdownEditor } from "#shared/editor";
|
||||
import { preview } from "#shared/proses";
|
||||
import { button, checkbox, combobox, foldable, input, multiselect, numberpicker, optionmenu, select, tabgroup, table, toggle, type Option } from "#shared/components";
|
||||
import { confirm, contextmenu, fullblocker, tooltip } from "#shared/floating";
|
||||
import { ABILITIES, abilityTexts, ALIGNMENTS, alignmentTexts, colorByRarity, damageTypeTexts, elementTexts, LEVELS, MAIN_STATS, mainStatShortTexts, mainStatTexts, masteryTexts, rarityText, RESISTANCES, resistanceTexts, SPELL_ELEMENTS, SPELL_TYPES, spellTypeTexts, subnameFactory, weaponTypeTexts } from "#shared/character";
|
||||
import { ABILITIES, abilityTexts, ALIGNMENTS, alignmentTexts, colorByRarity, DAMAGE_TYPES, damageTypeTexts, elementTexts, LEVELS, MAIN_STATS, mainStatShortTexts, mainStatTexts, masteryTexts, rarityText, RESISTANCES, resistanceTexts, SPELL_ELEMENTS, SPELL_TYPES, spellTypeTexts, subnameFactory, weaponTypeTexts } from "#shared/character";
|
||||
import characterConfig from "#shared/character-config.json";
|
||||
import { getID } from "#shared/general";
|
||||
import markdown, { markdownReference, renderMDAsText } from "#shared/markdown";
|
||||
@@ -600,7 +600,7 @@ export class HomebrewBuilder
|
||||
}
|
||||
}
|
||||
|
||||
type FeatureOption = Partial<FeatureValue | FeatureEquipment | FeatureList | FeatureChoice | FeatureTree> & { id: string };
|
||||
type FeatureOption = Partial<FeatureValue | FeatureState | FeatureEquipment | FeatureList | FeatureChoice | FeatureTree> & { id: string };
|
||||
class FeatureEditor
|
||||
{
|
||||
private _list: Record<string, FeatureOption> | FeatureOption[];
|
||||
@@ -701,6 +701,8 @@ class FeatureEditor
|
||||
{
|
||||
case 'value':
|
||||
return this.editValue(buffer as Partial<FeatureValue>);
|
||||
case 'state':
|
||||
return this.editState(buffer as Partial<FeatureState>);
|
||||
case 'list':
|
||||
return this.editList(buffer as Partial<FeatureList>);
|
||||
case 'choice':
|
||||
@@ -731,6 +733,16 @@ class FeatureEditor
|
||||
div('px-2 py-1 flex items-center flex-1', [summaryText])
|
||||
] };
|
||||
}
|
||||
private editState(buffer: Partial<FeatureState>)
|
||||
{
|
||||
const summaryText = text(textFromEffect(buffer));
|
||||
|
||||
return { top: [
|
||||
input('text', { defaultValue: buffer.value, change: e => { buffer.value = e; summaryText.textContent = textFromEffect(buffer); } }),
|
||||
], bottom: [
|
||||
div('px-2 py-1 flex items-center flex-1', [summaryText])
|
||||
] };
|
||||
}
|
||||
private editList(buffer: Partial<FeatureList>)
|
||||
{
|
||||
let list: Option<string>[] = [];
|
||||
@@ -1056,8 +1068,15 @@ const featureChoices: Option<Partial<FeatureOption>>[] = [
|
||||
{ text: 'Mod. de curiosité', effects: [ { category: 'value', property: 'modifier/curiosity', operation: 'add', value: 1 } ] },
|
||||
{ text: 'Mod. de charisme', effects: [ { category: 'value', property: 'modifier/charisma', operation: 'add', value: 1 } ] },
|
||||
{ text: 'Mod. de psyché', effects: [ { category: 'value', property: 'modifier/psyche', operation: 'add', value: 1 } ] }
|
||||
]} as Partial<FeatureItem>}
|
||||
]} as Partial<FeatureChoice>}
|
||||
] },
|
||||
{ text: 'Type de dégat', value: DAMAGE_TYPES.map(e => ({
|
||||
text: damageTypeTexts[e], value: [
|
||||
{ text: `${damageTypeTexts[e]} > Résistance`, value: { category: 'state', property: `bonus/damage/${e}`, value: 'resistance' } },
|
||||
{ text: `${damageTypeTexts[e]} > Immunité`, value: { category: 'state', property: `bonus/damage/${e}`, value: 'immunity' } },
|
||||
{ text: `${damageTypeTexts[e]} > Vulnérabilité`, value: { category: 'state', property: `bonus/damage/${e}`, value: 'vulnerability' } }
|
||||
]
|
||||
})) },
|
||||
{ text: 'Jet de résistance', value: [
|
||||
{ text: 'Résistance > Force', value: { category: 'value', property: 'bonus/defense/strength', operation: 'add', value: 1 } },
|
||||
{ text: 'Résistance > Dextérité', value: { category: 'value', property: 'bonus/defense/dexterity', operation: 'add', value: 1 } },
|
||||
@@ -1082,18 +1101,15 @@ const featureChoices: Option<Partial<FeatureOption>>[] = [
|
||||
{ text: 'Rang > Sorts de précision', value: { category: 'value', property: 'spellranks/precision', operation: 'add', value: 1 } },
|
||||
{ text: 'Rang > Sorts de savoir', value: { category: 'value', property: 'spellranks/knowledge', operation: 'add', value: 1 } },
|
||||
{ text: 'Rang > Sorts d\'instinct', value: { category: 'value', property: 'spellranks/instinct', operation: 'add', value: 1 } },
|
||||
{ text: 'Rang > Œuvres', value: { category: 'value', property: 'spellranks/arts', operation: 'add', value: 1 } },
|
||||
] },
|
||||
{ text: 'Bonus par type', value: [
|
||||
{ text: 'Bonus > Précision', value: { category: 'value', property: 'bonus/spells/type/precision', operation: 'add', value: 1 } },
|
||||
{ text: 'Bonus > Savoir', value: { category: 'value', property: 'bonus/spells/type/knowledge', operation: 'add', value: 1 } },
|
||||
{ text: 'Bonus > Instinct', value: { category: 'value', property: 'bonus/spells/type/instinct', operation: 'add', value: 1 } },
|
||||
{ text: 'Bonus > Œuvres', value: { category: 'value', property: 'bonus/spells/type/arts', operation: 'add', value: 1 } },
|
||||
{ text: 'Bonus > Choix par type', value: { category: 'choice', options: [
|
||||
{ text: 'Précision', effects: [{ category: 'value', property: 'bonus/spells/type/precision', operation: 'add', value: 1 }] },
|
||||
{ text: 'Savoir', effects: [{ category: 'value', property: 'bonus/spells/type/knowledge', operation: 'add', value: 1 }] },
|
||||
{ text: 'Instinct', effects: [{ category: 'value', property: 'bonus/spells/type/instinct', operation: 'add', value: 1 }] },
|
||||
{ text: 'Œuvres', effects: [{ category: 'value', property: 'bonus/spells/type/arts', operation: 'add', value: 1 }] },
|
||||
] } as Partial<FeatureChoice> }
|
||||
]},
|
||||
{ text: 'Bonus par rang', value: [
|
||||
@@ -1228,6 +1244,10 @@ function textFromEffect(effect: Partial<FeatureOption>): string
|
||||
|
||||
return `Inconnu ("${effect.property}")`;
|
||||
}
|
||||
else if(effect.category === 'state')
|
||||
{
|
||||
return `Inconnu (state)`;
|
||||
}
|
||||
else if(effect.category === 'list')
|
||||
{
|
||||
switch(effect.list)
|
||||
|
||||
Reference in New Issue
Block a user