You've already forked obsidian-visualiser
Add CharacterBuilder class to unify and compile the features
This commit is contained in:
@@ -1,20 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import config from '#shared/character-config.json';
|
||||
import { ABILITIES, defaultCharacter, MAIN_STATS, type Ability, type Character, type CharacterConfig, type MainStat } from '~/types/character';
|
||||
import characterConfig from '#shared/character-config.json';
|
||||
import { Icon } from '@iconify/vue/dist/iconify.js';
|
||||
import { CharacterBuilder, defaultCharacter } from '~/shared/character';
|
||||
import type { Character, CharacterConfig } from '~/types/character';
|
||||
|
||||
export interface EditorValues
|
||||
{
|
||||
health: number,
|
||||
mana: number,
|
||||
training: number,
|
||||
trainingSpent: number,
|
||||
abilities: Record<Ability, number>,
|
||||
abilitiesMax: Record<Ability, number>,
|
||||
modifiers: Record<MainStat, number>,
|
||||
}
|
||||
|
||||
const stepTexts = {
|
||||
const stepTexts: Record<number, string> = {
|
||||
0: 'Choisissez un peuple afin de définir la progression de votre personnage au fil des niveaux.',
|
||||
1: 'Déterminez la progression de votre personnage en choisissant une option par niveau disponible.',
|
||||
2: 'Spécialisez votre personnage en attribuant vos points d\'entrainement parmi les 7 branches disponibles.\nChaque paliers de 3 points augmentent votre modifieur.',
|
||||
@@ -27,21 +17,12 @@ definePageMeta({
|
||||
});
|
||||
let id = useRouter().currentRoute.value.params.id;
|
||||
const { add } = useToast();
|
||||
const characterConfig = config as CharacterConfig;
|
||||
const config = characterConfig as CharacterConfig;
|
||||
const data = ref<Character>({ ...defaultCharacter });
|
||||
const builder = markRaw(new CharacterBuilder(data.value));
|
||||
|
||||
const step = ref(0);
|
||||
|
||||
const values: EditorValues = reactive({
|
||||
health: 0,
|
||||
mana: 0,
|
||||
training: 0,
|
||||
trainingSpent: 0,
|
||||
abilities: Object.fromEntries(ABILITIES.map(e => [e, 0])) as Record<Ability, number>,
|
||||
abilitiesMax: Object.fromEntries(ABILITIES.map(e => [e, 0])) as Record<Ability, number>,
|
||||
modifiers: Object.fromEntries(MAIN_STATS.map(e => [e, 0])) as Record<MainStat, number>,
|
||||
});
|
||||
|
||||
if(id !== 'new')
|
||||
{
|
||||
const character = await useRequestFetch()(`/api/character/${id}`);
|
||||
@@ -115,20 +96,20 @@ useShortcuts({
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-1 outline-none max-w-full w-full overflow-y-auto" v-show="step === 0">
|
||||
<PeopleSelector v-model="data" :config="characterConfig" @next="step = 1" />
|
||||
<PeopleSelector v-model="builder" :config="config" @next="step = 1" />
|
||||
</div>
|
||||
<div class="flex-1 outline-none max-w-full w-full overflow-y-auto" v-show="step === 1">
|
||||
<LevelEditor v-model="data" :config="characterConfig" @next="step = 2" />
|
||||
<LevelEditor v-model="builder" :config="config" @next="step = 2" />
|
||||
</div>
|
||||
<div class="flex-1 outline-none max-w-full w-full h-full max-h-full overflow-y-auto" v-show="step === 2">
|
||||
<TrainingEditor v-model="data" :config="characterConfig" @next="step = 3" />
|
||||
<!-- <div class="flex-1 outline-none max-w-full w-full h-full max-h-full overflow-y-auto" v-show="step === 2">
|
||||
<TrainingEditor v-model="builder" :config="config" @next="step = 3" />
|
||||
</div>
|
||||
<div class="flex-1 outline-none max-w-full w-fulloverflow-y-auto" v-show="step === 3">
|
||||
<AbilityEditor v-model="data" :config="characterConfig" @next="step = 4" />
|
||||
<AbilityEditor v-model="builder" :config="config" @next="step = 4" />
|
||||
</div>
|
||||
<div class="flex-1 outline-none max-w-full w-full overflow-y-auto" v-show="step === 4">
|
||||
<AspectSelector v-model="data" :config="characterConfig" @next="save(true)" />
|
||||
</div>
|
||||
<AspectSelector v-model="builder" :config="config" @next="save(true)" />
|
||||
</div> -->
|
||||
</StepperRoot>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user