diff --git a/src/module/sheets/characterSheet.mjs b/src/module/sheets/characterSheet.mjs index d0b6e6ec..61a24c2a 100644 --- a/src/module/sheets/characterSheet.mjs +++ b/src/module/sheets/characterSheet.mjs @@ -126,8 +126,12 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) { * @param {MouseEvent} event */ static #openEmbeddedDocument(event) { - const dataset = event.target.dataset + let dataset = event.target.dataset + if (!dataset.itemId || !dataset.id) { + dataset = event.target.parentElement.dataset + } const id = dataset.itemId ?? dataset.id + this.document.items.get(id).sheet.render(true) } diff --git a/src/module/xml-import/xml-import.mjs b/src/module/xml-import/xml-import.mjs index f9baaed2..71250d7e 100644 --- a/src/module/xml-import/xml-import.mjs +++ b/src/module/xml-import/xml-import.mjs @@ -4,6 +4,7 @@ import {Profession} from "../documents/profession.mjs"; import {Culture} from "../documents/culture.mjs"; import {Species} from "../documents/species.mjs"; import {SpecialAbility} from "../documents/specialAbility.mjs"; +import {Equipment} from "../documents/equipment.mjs"; export class XmlImport { #months = [ @@ -199,9 +200,10 @@ export class XmlImport { json.meta.titel = held.basis.rasse.aussehen.titel json.meta.stand = held.basis.rasse.aussehen.stand } - let attributes = held.eigenschaften.eigenschaft - json.attribute = {} if (!options.skipAttributes) { + let attributes = held.eigenschaften.eigenschaft + json.attribute = {} + if (held.basis.gilde) { json.attribute.gilde = held.basis.gilde.name } @@ -235,7 +237,6 @@ export class XmlImport { } json.attribute.so = this.#getAttributeJson(attributes, "Sozialstatus") } - if (!options.skipAdvantages) this.#mapAdvantages(actor, held) let specialAbilities = [] let liturgies = [] @@ -291,6 +292,7 @@ export class XmlImport { if (!options.skipSkills) this.#mapSkills(actor, held, combatValues) if (!options.skipSpells) this.#mapSpells(actor, held) if (!options.skipLiturgies) this.#mapLiturgies(actor, liturgies) + if (!options.skipEquipment) this.#mapEquipment(actor, held) let notes = [] for (let note in held.kommentare) { @@ -487,6 +489,49 @@ export class XmlImport { } } + #mapEquipment(actor, held) { + if (actor.itemTypes["Equipment"].length > 0) { + actor.itemTypes["Equipment"].forEach(e => { + actor.items.get(e._id).delete() + }) + } + held.gegenstände.gegenstand.forEach(e => { + const compendiumOfArmor = game.packs.get('DSA_4-1.Armor'); + const compendiumOfWeapons = game.packs.get('DSA_4-1.Weapons'); + const compendiumOfAmmunition = game.packs.get('DSA_4-1.Ammunition'); + let eId = null + let compendium = null + if (compendiumOfArmor?.index.find(p => p.name === e.name)) { + eId = compendiumOfArmor?.index.find(p => p.name === e.name) + compendium = compendiumOfArmor + } + if (compendiumOfWeapons?.index.find(p => p.name === e.name)) { + eId = compendiumOfWeapons?.index.find(p => p.name === e.name) + compendium = compendiumOfWeapons + } + if (compendiumOfAmmunition?.index.find(p => p.name === e.name)) { + eId = compendiumOfAmmunition?.index.find(p => p.name === e.name) + compendium = compendiumOfAmmunition + } + + if (eId && compendium) { + compendium.getDocument(eId._id).then(sf => actor.createEmbeddedDocuments('Item', [sf])) + } else { + actor.createEmbeddedDocuments('Item', [new Equipment( + { + name: e.modallgemein?.name?.value ?? e.name, + type: "Equipment", + system: { + quantity: e.anzahl, + price: e.modallgemein?.preis.value, + weight: e.modallgemein?.gewicht.value, + + } + })]) + } + }) + } + async #mapProfessions(actor, professions) { if (actor.itemTypes["Profession"].length > 0) { actor.itemTypes["Profession"].forEach(p => {