added racevariant parsing
This commit is contained in:
@@ -1,10 +1,16 @@
|
|||||||
import type {CharacterData} from "../../../../../types/CharacterJson.ts";
|
import type {CharacterData} from "../../../../../types/CharacterJson.ts";
|
||||||
import type {AttributeWithValue} from "../../../../../utils/loaders";
|
import {
|
||||||
import {useState, useEffect} from 'react';
|
type AttributeWithValue,
|
||||||
import {loadRace, loadProfession, loadAttributesWithValues} from "../../../../../utils/loaders";
|
loadAttributesWithValues,
|
||||||
|
loadProfession,
|
||||||
|
loadRace,
|
||||||
|
loadRaceVariant
|
||||||
|
} from "../../../../../utils/loaders";
|
||||||
|
import {useEffect, useState} from 'react';
|
||||||
|
|
||||||
export default function SheetHeader({jsonData}: { jsonData: CharacterData }) {
|
export default function SheetHeader({jsonData}: { jsonData: CharacterData }) {
|
||||||
const [raceName, setRaceName] = useState<string>(jsonData.r);
|
const [raceName, setRaceName] = useState<string>(jsonData.r);
|
||||||
|
const [raceVariantName, setRaceVariantName] = useState<string>(jsonData.rv || '');
|
||||||
const [professionName, setProfessionName] = useState<string>(jsonData.p);
|
const [professionName, setProfessionName] = useState<string>(jsonData.p);
|
||||||
const [attributes, setAttributes] = useState<AttributeWithValue[]>([]);
|
const [attributes, setAttributes] = useState<AttributeWithValue[]>([]);
|
||||||
|
|
||||||
@@ -14,8 +20,9 @@ export default function SheetHeader({jsonData}: { jsonData: CharacterData }) {
|
|||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
try {
|
try {
|
||||||
// Load race and profession using the new loader functions
|
// Load race and profession using the new loader functions
|
||||||
const [race, profession] = await Promise.all([
|
const [race, raceVariant, profession] = await Promise.all([
|
||||||
loadRace(jsonData.r),
|
loadRace(jsonData.r),
|
||||||
|
loadRaceVariant(jsonData.rv || ''),
|
||||||
loadProfession(jsonData.p)
|
loadProfession(jsonData.p)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -24,6 +31,7 @@ export default function SheetHeader({jsonData}: { jsonData: CharacterData }) {
|
|||||||
|
|
||||||
if (isMounted) {
|
if (isMounted) {
|
||||||
setRaceName(race?.name || jsonData.r);
|
setRaceName(race?.name || jsonData.r);
|
||||||
|
setRaceVariantName(raceVariant?.name|| '');
|
||||||
// For profession, handle gendered name
|
// For profession, handle gendered name
|
||||||
if (profession?.name) {
|
if (profession?.name) {
|
||||||
setProfessionName(profession.name.m || profession.name.f || jsonData.p);
|
setProfessionName(profession.name.m || profession.name.f || jsonData.p);
|
||||||
@@ -47,7 +55,7 @@ export default function SheetHeader({jsonData}: { jsonData: CharacterData }) {
|
|||||||
return () => {
|
return () => {
|
||||||
isMounted = false;
|
isMounted = false;
|
||||||
};
|
};
|
||||||
}, [jsonData.r, jsonData.p, jsonData.attr]);
|
}, [jsonData.r, jsonData.rv, jsonData.p, jsonData.attr]);
|
||||||
|
|
||||||
console.log(jsonData)
|
console.log(jsonData)
|
||||||
|
|
||||||
@@ -62,7 +70,7 @@ export default function SheetHeader({jsonData}: { jsonData: CharacterData }) {
|
|||||||
</div>
|
</div>
|
||||||
<div className="w-[30%]">
|
<div className="w-[30%]">
|
||||||
<p className="border-b border-gray-500 font-semibold">
|
<p className="border-b border-gray-500 font-semibold">
|
||||||
{raceName}
|
{raceName} {raceVariantName ? <>({raceVariantName})</> : ''}
|
||||||
</p>
|
</p>
|
||||||
<small>Spezies</small>
|
<small>Spezies</small>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -87,6 +87,7 @@ export interface CharacterData {
|
|||||||
ap: AdventurePoints;
|
ap: AdventurePoints;
|
||||||
el: string; // Experience Level
|
el: string; // Experience Level
|
||||||
r: string; // Race
|
r: string; // Race
|
||||||
|
rv?: string;// Race_Variant
|
||||||
c: string; // Culture
|
c: string; // Culture
|
||||||
p: string; // Profession
|
p: string; // Profession
|
||||||
sex: string;
|
sex: string;
|
||||||
|
@@ -49,6 +49,7 @@ import type {AnimistForce} from '../types/AnimistForce';
|
|||||||
// import type { RogueSpell } from '../types/RogueSpell';
|
// import type { RogueSpell } from '../types/RogueSpell';
|
||||||
// import type { SkillGroup } from '../types/SkillGroup';
|
// import type { SkillGroup } from '../types/SkillGroup';
|
||||||
import type {Skill} from '../types/Skill';
|
import type {Skill} from '../types/Skill';
|
||||||
|
import type {RaceVariant} from "../types/RaceVariant.ts";
|
||||||
// import type { SocialStatuse } from '../types/SocialStatuse';
|
// import type { SocialStatuse } from '../types/SocialStatuse';
|
||||||
// import type { SpecialAbilitie } from '../types/SpecialAbilitie';
|
// import type { SpecialAbilitie } from '../types/SpecialAbilitie';
|
||||||
// import type { SpecialAbilityGroup } from '../types/SpecialAbilityGroup';
|
// import type { SpecialAbilityGroup } from '../types/SpecialAbilityGroup';
|
||||||
@@ -136,6 +137,11 @@ export async function loadRace(id: string): Promise<Race | undefined> {
|
|||||||
return getItemById<Race>('Races.json', id);
|
return getItemById<Race>('Races.json', id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Race_Variant loader
|
||||||
|
export async function loadRaceVariant(id: string): Promise<RaceVariant | undefined> {
|
||||||
|
return getItemById<RaceVariant>('RaceVariants.json', id);
|
||||||
|
}
|
||||||
|
|
||||||
// Profession loader
|
// Profession loader
|
||||||
export async function loadProfession(id: string): Promise<Profession | undefined> {
|
export async function loadProfession(id: string): Promise<Profession | undefined> {
|
||||||
return getItemById<Profession>('Professions.json', id);
|
return getItemById<Profession>('Professions.json', id);
|
||||||
|
Reference in New Issue
Block a user