From 9e7428d58994d872dd5cde97bbc848a7c9a081ce Mon Sep 17 00:00:00 2001 From: Jendrik Date: Thu, 25 Sep 2025 23:13:38 +0200 Subject: [PATCH] fixed json array problem --- src/module/xml-import/xml-import.mjs | 51 ++++++++++++++-------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/module/xml-import/xml-import.mjs b/src/module/xml-import/xml-import.mjs index f88ab7ae..f203eb16 100644 --- a/src/module/xml-import/xml-import.mjs +++ b/src/module/xml-import/xml-import.mjs @@ -114,7 +114,7 @@ function mapRawJson(rawJson) { json.meta.spezies = held.basis.rasse.string json.meta.kultur = held.basis.kultur.string let professions = [] - for (let ausbildung in held.basis.ausbildungen) { + for (let ausbildung in held.basis.ausbildungen.ausbildung) { if (ausbildung.tarnidentitaet) { professions = [ausbildung.tarnidentitaet] break; @@ -146,59 +146,60 @@ function mapRawJson(rawJson) { ] json.titel = held.basis.rasse.aussehen.titel json.stand = held.basis.rasse.aussehen.stand + let attributes = held.eigenschaften.eigenschaft json.attribute = {} - json.attribute.mu = getAttributeJson(held.eigenschaften, "Mut") - json.attribute.kl = getAttributeJson(held.eigenschaften, "Klugheit") - json.attribute.in = getAttributeJson(held.eigenschaften, "Intuition") - json.attribute.ch = getAttributeJson(held.eigenschaften, "Charisma") - json.attribute.ff = getAttributeJson(held.eigenschaften, "Fingerfertigkeit") - json.attribute.ge = getAttributeJson(held.eigenschaften, "Gewandtheit") - json.attribute.ko = getAttributeJson(held.eigenschaften, "Konstitution") - json.attribute.kk = getAttributeJson(held.eigenschaften, "Körperkraft") + json.attribute.mu = getAttributeJson(attributes, "Mut") + json.attribute.kl = getAttributeJson(attributes, "Klugheit") + json.attribute.in = getAttributeJson(attributes, "Intuition") + json.attribute.ch = getAttributeJson(attributes, "Charisma") + json.attribute.ff = getAttributeJson(attributes, "Fingerfertigkeit") + json.attribute.ge = getAttributeJson(attributes, "Gewandtheit") + json.attribute.ko = getAttributeJson(attributes, "Konstitution") + json.attribute.kk = getAttributeJson(attributes, "Körperkraft") json.attribute.mr = { - mod: filterAttribute(held.eigenschaften ,"Magieresistenz").mod + mod: filterAttribute(attributes,"Magieresistenz").mod } json.attribute.lep = { - mod: filterAttribute(held.eigenschaften ,"Lebensenergie").mod + mod: filterAttribute(attributes,"Lebensenergie").mod } json.attribute.aup = { - mod: filterAttribute(held.eigenschaften ,"Ausdauer").mod + mod: filterAttribute(attributes,"Ausdauer").mod } json.attribute.asp = { - mod: filterAttribute(held.eigenschaften ,"Astralenergie").mod + mod: filterAttribute(attributes,"Astralenergie").mod } json.attribute.kap = { - mod: filterAttribute(held.eigenschaften ,"Karmaenergie").mod + mod: filterAttribute(attributes,"Karmaenergie").mod } - let attribute = filterAttribute(held.eigenschaften ,"Karmaenergie") + let attribute = filterAttribute(attributes,"Karmaenergie") json.attribute.at = { mod: attribute.mod, aktuell: attribute.value } - attribute = filterAttribute(held.eigenschaften ,"at") + attribute = filterAttribute(attributes,"at") json.attribute.pa = { mod: attribute.mod, aktuell: attribute.value } - attribute = filterAttribute(held.eigenschaften ,"pa") + attribute = filterAttribute(attributes,"pa") json.attribute.at = { mod: attribute.mod, aktuell: attribute.value } - attribute = filterAttribute(held.eigenschaften ,"fk") + attribute = filterAttribute(attributes,"fk") json.attribute.fk = { mod: attribute.mod, aktuell: attribute.value } - attribute = filterAttribute(held.eigenschaften ,"ini") + attribute = filterAttribute(attributes,"ini") json.attribute.ini = { mod: attribute.mod, aktuell: attribute.value } - json.attribute.so = getAttributeJson(held.eigenschaften, "Sozialstatus") + json.attribute.so = getAttributeJson(attributes, "Sozialstatus") let specialAbilities = [] let liturgies = [] - for (let specialAbility in held.sf) { + for (let specialAbility in held.sf.sonderfertigkeit) { if (specialAbility.name.startsWith("Liturgie:")) { liturgies.push({ name: specialAbility.name.replace("Liturgie:", "").trim(), @@ -216,7 +217,7 @@ function mapRawJson(rawJson) { if (choices.hasOwnProperty("name")) { specialAbilityJson.auswahlen.push(choices.name) } else { - for (let choice in choices) { + for (let choice in choices.wahl) { specialAbilityJson.auswahlen.push(choice.value) } } @@ -229,7 +230,7 @@ function mapRawJson(rawJson) { json.sonderfertigkeiten = specialAbilities json.liturgien = liturgies let talents = [] - for (let talent in held.talentliste) { + for (let talent in held.talentliste.talent) { talents.push({ name: talent.name, taw: talent.value, @@ -240,7 +241,7 @@ function mapRawJson(rawJson) { } json.talente = talents let spells = [] - for (let spell in held.zauberliste) { + for (let spell in held.zauberliste.zauber) { spells.push({ name: spell.name, rep: spell.repraesentation, @@ -252,7 +253,7 @@ function mapRawJson(rawJson) { } json.zauber = spells let combatValues = [] - for (let combatValue in held.kampfwerte) { + for (let combatValue in held.kampf.kampfwerte) { combatValues.push({ name: combatValue.name, at: combatValue.attacke.value,