You've already forked obsidian-visualiser
New ability display, sereval Character compile and creation fixes
This commit is contained in:
@@ -29,7 +29,7 @@ export const defaultCharacter: Character = {
|
||||
people: undefined,
|
||||
level: 1,
|
||||
|
||||
training: MAIN_STATS.reduce((p, v) => { p[v] = { 0: 0 }; return p; }, {} as Record<MainStat, Partial<Record<TrainingLevel, number>>>),
|
||||
training: MAIN_STATS.reduce((p, v) => { p[v] = { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0 }; return p; }, {} as Record<MainStat, Partial<Record<TrainingLevel, number>>>),
|
||||
leveling: { 1: 0 },
|
||||
abilities: {},
|
||||
choices: {},
|
||||
@@ -227,7 +227,7 @@ export const CharacterVariablesValidation = z.object({
|
||||
state: z.number().min(1).max(7).or(z.literal(true)),
|
||||
})),
|
||||
spells: z.array(z.string()),
|
||||
equipment: z.array(z.string()),
|
||||
items: z.array(z.string()),
|
||||
});
|
||||
export const CharacterValidation = z.object({
|
||||
id: z.number(),
|
||||
@@ -424,13 +424,16 @@ export class CharacterCompiler
|
||||
if(buffer && buffer._dirty === true)
|
||||
{
|
||||
let sum = 0, shortcut = false;
|
||||
for(let i = 0; i < buffer.list.length; i++)
|
||||
for(let j = 0; j < buffer.list.length; j++)
|
||||
{
|
||||
if(typeof buffer.list[i]!.value === 'string') // Add or set a modifier
|
||||
if(typeof buffer.list[j]!.value === 'string') // Add or set a modifier
|
||||
{
|
||||
const modifier = this._buffer[buffer.list[i]!.value as string];
|
||||
const modifier = this._buffer[buffer.list[j]!.value as string];
|
||||
if(!modifier)
|
||||
{
|
||||
if(!queue.includes(buffer.list[j]!.value as string))
|
||||
this._buffer[buffer.list[j]!.value as string] = { _dirty: false, list: [], min: -Infinity, value: 0 };
|
||||
|
||||
queue.push(property);
|
||||
shortcut = true;
|
||||
break;
|
||||
@@ -438,29 +441,29 @@ export class CharacterCompiler
|
||||
else if(modifier._dirty)
|
||||
{
|
||||
//Put it back in queue since its dependencies haven't been resolved yet
|
||||
queue.push(buffer.list[i]!.value as string);
|
||||
queue.push(buffer.list[j]!.value as string);
|
||||
queue.push(property);
|
||||
shortcut = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(buffer.list[i]?.operation === 'add')
|
||||
if(buffer.list[j]?.operation === 'add')
|
||||
sum += modifier.value;
|
||||
else if(buffer.list[i]?.operation === 'set')
|
||||
else if(buffer.list[j]?.operation === 'set')
|
||||
sum = modifier.value;
|
||||
else if(buffer.list[i]?.operation === 'min')
|
||||
else if(buffer.list[j]?.operation === 'min')
|
||||
this._buffer[property]!.min = modifier.value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(buffer.list[i]?.operation === 'add')
|
||||
sum += buffer.list[i]!.value as number;
|
||||
else if(buffer.list[i]?.operation === 'set')
|
||||
sum = buffer.list[i]!.value as number;
|
||||
else if(buffer.list[i]?.operation === 'min')
|
||||
this._buffer[property]!.min = buffer.list[i]!.value as number;
|
||||
if(buffer.list[j]?.operation === 'add')
|
||||
sum += buffer.list[j]!.value as number;
|
||||
else if(buffer.list[j]?.operation === 'set')
|
||||
sum = buffer.list[j]!.value as number;
|
||||
else if(buffer.list[j]?.operation === 'min')
|
||||
this._buffer[property]!.min = buffer.list[j]!.value as number;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1348,18 +1351,18 @@ export class CharacterSheet
|
||||
]),
|
||||
|
||||
div("flex flex-1 flex-row items-stretch justify-center py-2 gap-4", [
|
||||
div("flex flex-col gap-4 py-1 w-80", [
|
||||
div("flex flex-col gap-4 py-1 w-60", [
|
||||
div("flex flex-col py-1 gap-4", [
|
||||
div("flex flex-row items-center justify-center gap-4", [
|
||||
div("flex flex-row items-center justify-center gap-2", [ dom("div", { class: 'text-xl font-semibold', text: "Compétences" }), proses('a', preview, [ icon('radix-icons:question-mark-circled', { width: 16, height: 16, class: 'text-light-70 dark:text-dark-70' }) ], { href: 'regles/l\'entrainement/competences', size: 'small', class: 'h-4' }) ]),
|
||||
div("flex flex-1 border-t border-dashed border-light-50 dark:border-dark-50")
|
||||
]),
|
||||
|
||||
div("grid grid-cols-3 gap-2",
|
||||
div("grid grid-cols-2 gap-2",
|
||||
Object.entries(character.abilities).map(([ability, value]) =>
|
||||
div("flex flex-col px-2 items-center text-sm text-light-70 dark:text-dark-70", [
|
||||
dom("span", { class: "font-bold text-base text-light-100 dark:text-dark-100", text: `+${value}` }),
|
||||
dom("span", { text: abilityTexts[ability as Ability] || ability })
|
||||
div("flex flex-row px-1 justify-between items-center", [
|
||||
span("text-sm text-light-70 dark:text-dark-70 max-w-20 truncate", abilityTexts[ability as Ability] || ability),
|
||||
span("font-bold text-base text-light-100 dark:text-dark-100", `+${value}`),
|
||||
])
|
||||
)
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user