-
-
-
- {{ character.name }}
- Niveau {{ character.level }}
-
+
+
+
+
+
{{ character.name }}
+
+
+ Niveau {{ character.level }}
+
+ {{ config.peoples[character.people!]?.name }}
+
+
+
+
+
diff --git a/server/api/character.get.ts b/server/api/character.get.ts
index da9f8c7..aab48c5 100644
--- a/server/api/character.get.ts
+++ b/server/api/character.get.ts
@@ -25,7 +25,7 @@ export default defineEventHandler(async (e) => {
return;
}
- where = (character, { eq, and }) => and(eq(character.owner, session.user!.id), eq(character.visibility, "private"));
+ where = (character, { eq, and }) => and(eq(character.owner, session.user!.id));
}
else if(visibility === 'public')
{
diff --git a/server/api/character.post.ts b/server/api/character.post.ts
index 6ce4992..f4eef9e 100644
--- a/server/api/character.post.ts
+++ b/server/api/character.post.ts
@@ -37,12 +37,12 @@ export default defineEventHandler(async (e) => {
thumbnail: body.data.thumbnail,
}).returning({ id: characterTable.id }).get().id;
- if(Object.keys(body.data.leveling).length > 0) tx.insert(characterLevelingTable).values(Object.entries(body.data.leveling).map(e => ({ character: id, level: parseInt(e[0], 10), choice: e[1]! }))).run();
+ if(Object.keys(body.data.leveling).length > 0) tx.insert(characterLevelingTable).values(Object.entries(body.data.leveling).filter(e => e[1] !== undefined).map(e => ({ character: id, level: parseInt(e[0], 10), choice: e[1]! }))).run();
- const training = Object.entries(body.data.training).flatMap(e => Object.entries(e[1]).map(_e => ({ character: id, stat: e[0] as MainStat, level: parseInt(_e[0], 10), choice: _e[1]! })));
+ const training = Object.entries(body.data.training).flatMap(e => Object.entries(e[1]).filter(e => e[1] !== undefined).map(_e => ({ character: id, stat: e[0] as MainStat, level: parseInt(_e[0], 10), choice: _e[1]! })));
if(training.length > 0) tx.insert(characterTrainingTable).values(training).run();
- const abilities = Object.entries(body.data.abilities).map(e => ({ character: id, ability: e[0] as Ability, value: e[1] }));
+ const abilities = Object.entries(body.data.abilities).filter(e => e[1] !== undefined).map(e => ({ character: id, ability: e[0] as Ability, value: e[1] }));
if(abilities.length > 0) tx.insert(characterAbilitiesTable).values(abilities).run();
return id;
diff --git a/shared/character.util.ts b/shared/character.util.ts
index 90a2e87..91db6a0 100644
--- a/shared/character.util.ts
+++ b/shared/character.util.ts
@@ -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>>),
+ training: MAIN_STATS.reduce((p, v) => { p[v] = { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0 }; return p; }, {} as Record>>),
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}`),
])
)
),