Alignment handled as string instead of objects
This commit is contained in:
parent
893247e1eb
commit
6fe3746df4
|
|
@ -17,7 +17,7 @@ export const TRAINING_LEVELS = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] as const;
|
|||
export const SPELL_TYPES = ["precision","knowledge","instinct","arts"] as const;
|
||||
export const CATEGORIES = ["action","reaction","freeaction","misc"] as const;
|
||||
export const SPELL_ELEMENTS = ["fire","ice","thunder","earth","arcana","air","nature","light","psyche"] as const;
|
||||
export const ALIGNMENTS: Alignment[] = [{ kindness: 'good', loyalty: 'loyal' }, { kindness: 'good', loyalty: 'neutral' }, { kindness: 'good', loyalty: 'chaotic' }, { kindness: 'neutral', loyalty: 'loyal' }, { kindness: 'neutral', loyalty: 'neutral' }, { kindness: 'neutral', loyalty: 'chaotic' }, { kindness: 'evil', loyalty: 'loyal' }, { kindness: 'evil', loyalty: 'neutral' }, { kindness: 'evil', loyalty: 'chaotic' }];
|
||||
export const ALIGNMENTS = ['loyal_good', 'neutral_good', 'chaotic_good', 'loyal_neutral', 'neutral_neutral', 'chaotic_neutral', 'loyal_evil', 'neutral_evil', 'chaotic_evil'] as const;
|
||||
|
||||
export const defaultCharacter: Character = {
|
||||
id: -1,
|
||||
|
|
@ -158,18 +158,17 @@ export const elementTexts: Record<SpellElement, { class: string, text: string }>
|
|||
psyche: { class: 'text-light-purple dark:text-dark-purple border-light-purple dark:border-dark-purple bg-light-purple dark:bg-dark-purple', text: 'Psy' },
|
||||
};
|
||||
|
||||
export function alignmentToString(alignment: Alignment): string
|
||||
{
|
||||
switch(alignment.loyalty)
|
||||
{
|
||||
case 'chaotic':
|
||||
return alignment.kindness === 'evil' ? 'Chaotique mauvais' : alignment.kindness === 'neutral' ? 'Chaotique neutre' : 'Chaotique bon';
|
||||
case 'loyal':
|
||||
return alignment.kindness === 'evil' ? 'Loyal mauvais' : alignment.kindness === 'neutral' ? 'Loyal neutre' : 'Loyal bon';
|
||||
case 'neutral':
|
||||
return alignment.kindness === 'evil' ? 'Neutre mauvais' : alignment.kindness === 'neutral' ? 'Neutre' : 'Neutre bon';
|
||||
}
|
||||
}
|
||||
export const alignmentTexts: Record<Alignment, string> = {
|
||||
'loyal_good': 'Loyal bon',
|
||||
'neutral_good': 'Neutre bon',
|
||||
'chaotic_good': 'Chaotique bon',
|
||||
'loyal_neutral': 'Loyal neutre',
|
||||
'neutral_neutral': 'Neutre',
|
||||
'chaotic_neutral': 'Chaotique neutre',
|
||||
'loyal_evil': 'Loyal mauvais',
|
||||
'neutral_evil': 'Neutre mauvais',
|
||||
'chaotic_evil': 'Chaotique mauvais',
|
||||
};
|
||||
export const spellTypeTexts: Record<SpellType, string> = { "instinct": "Instinct", "knowledge": "Savoir", "precision": "Précision", "arts": "Oeuvres" };
|
||||
|
||||
export const CharacterValidation = z.object({
|
||||
|
|
@ -252,6 +251,13 @@ export class CharacterCompiler
|
|||
}, {} as Record<string, number>);
|
||||
}
|
||||
|
||||
parse(text: string): string
|
||||
{
|
||||
return text.replace(/\{(.*?)\}/gmi, (substring: string, group: string) => {
|
||||
console.log(substring, group);
|
||||
return substring;
|
||||
})
|
||||
}
|
||||
protected add(feature?: string)
|
||||
{
|
||||
if(!feature)
|
||||
|
|
@ -1079,7 +1085,7 @@ class AspectPicker implements BuilderTab
|
|||
]),
|
||||
div('w-px h-full bg-light-50 dark:bg-dark-50'),
|
||||
div('flex flex-col items-center justify-between py-2', [
|
||||
div('text-sm italic', [ text(alignmentToString(e.alignment)) ]),
|
||||
div('text-sm italic', [ text(alignmentTexts[e.alignment]) ]),
|
||||
div(['text-sm font-bold', { "text-light-purple dark:text-dark-purple italic": e.magic, "text-light-orange dark:text-dark-orange": !e.magic }], [ text(e.magic ? 'Magie autorisée' : 'Magie interdite') ]),
|
||||
]),
|
||||
])
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { MarkdownEditor } from "#shared/editor.util";
|
|||
import { fakeA } from "#shared/proses";
|
||||
import { button, combobox, foldable, input, multiselect, numberpicker, select, table, toggle, type Option } from "#shared/components.util";
|
||||
import { fullblocker, tooltip } from "#shared/floating.util";
|
||||
import { ALIGNMENTS, alignmentToString, elementTexts, MAIN_STATS, mainStatShortTexts, mainStatTexts, SPELL_ELEMENTS, SPELL_TYPES, spellTypeTexts } from "#shared/character.util";
|
||||
import { ALIGNMENTS, alignmentTexts, elementTexts, MAIN_STATS, mainStatShortTexts, mainStatTexts, SPELL_ELEMENTS, SPELL_TYPES, spellTypeTexts } from "#shared/character.util";
|
||||
import characterConfig from "#shared/character-config.json";
|
||||
import { getID, ID_SIZE } from "#shared/general.util";
|
||||
import renderMarkdown, { renderText } from "#shared/markdown.util";
|
||||
|
|
@ -194,7 +194,7 @@ class AspectEditor extends BuilderTab
|
|||
name: input('text', { input: (value) => aspect.name = value, defaultValue: aspect.name, class: '!m-0 w-full' }),
|
||||
description: input('text', { input: (value) => aspect.description = value, defaultValue: aspect.description, class: '!m-0 w-full' }),
|
||||
stat: select(MAIN_STATS.map(f => ({ text: mainStatTexts[f], value: f })), { change: (value) => aspect.stat = value, defaultValue: aspect.stat, class: { container: '!m-0 w-full' } }),
|
||||
alignment: select(ALIGNMENTS.map(f => ({ text: alignmentToString(f), value: f })), { change: (value) => aspect.alignment = value, defaultValue: aspect.alignment, class: { container: '!m-0 w-full' } }),
|
||||
alignment: select(ALIGNMENTS.map(f => ({ text: alignmentTexts[f], value: f })), { change: (value) => aspect.alignment = value, defaultValue: aspect.alignment, class: { container: '!m-0 w-full' } }),
|
||||
magic: toggle({ defaultValue: aspect.magic, change: (value) => aspect.magic = value, class: { container: '' } }),
|
||||
difficulty: numberpicker({ min: 6, max: 13, input: (value) => aspect.difficulty = value, defaultValue: aspect.difficulty, class: '!m-0 w-full' }),
|
||||
physic: div('flex flex-row justify-center gap-2', [ numberpicker({ defaultValue: aspect.physic.min, input: (value) => aspect.physic.min = value }), numberpicker({ defaultValue: aspect.physic.max, input: (value) => aspect.physic.max = value }) ]),
|
||||
|
|
@ -208,7 +208,7 @@ class AspectEditor extends BuilderTab
|
|||
name: '',
|
||||
description: '',
|
||||
stat: 'strength',
|
||||
alignment: { kindness: 'good', loyalty: 'loyal' },
|
||||
alignment: 'loyal_good',
|
||||
magic: false,
|
||||
difficulty: 6,
|
||||
physic: { min: 0, max: 30 },
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { popper } from "#shared/floating.util";
|
|||
import { Canvas } from "#shared/canvas.util";
|
||||
import { Content, iconByType, type LocalContent } from "#shared/content.util";
|
||||
import { unifySlug } from "#shared/general.util";
|
||||
import { loading } from "./components.util";
|
||||
|
||||
|
||||
export type CustomProse = (properties: any, children: NodeChildren) => Node;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { MAIN_STATS, ABILITIES, LEVELS, TRAINING_LEVELS, SPELL_TYPES, CATEGORIES, SPELL_ELEMENTS } from "#shared/character.util";
|
||||
import type { MAIN_STATS, ABILITIES, LEVELS, TRAINING_LEVELS, SPELL_TYPES, CATEGORIES, SPELL_ELEMENTS, ALIGNMENTS } from "#shared/character.util";
|
||||
|
||||
export type MainStat = typeof MAIN_STATS[number];
|
||||
export type Ability = typeof ABILITIES[number];
|
||||
|
|
@ -7,10 +7,10 @@ export type TrainingLevel = typeof TRAINING_LEVELS[number];
|
|||
export type SpellType = typeof SPELL_TYPES[number];
|
||||
export type Category = typeof CATEGORIES[number];
|
||||
export type SpellElement = typeof SPELL_ELEMENTS[number];
|
||||
export type Alignment = typeof ALIGNMENTS[number];
|
||||
|
||||
export type FeatureID = string;
|
||||
export type Resistance = string;
|
||||
export type Alignment = { loyalty: 'loyal' | 'neutral' | 'chaotic', kindness: 'good' | 'neutral' | 'evil' };
|
||||
|
||||
export type Character = {
|
||||
id: number;
|
||||
|
|
|
|||
Loading…
Reference in New Issue