adds import of equipment
parent
b49f945a74
commit
c4863b4493
|
|
@ -126,8 +126,12 @@ class CharacterSheet extends HandlebarsApplicationMixin(ActorSheetV2) {
|
||||||
* @param {MouseEvent} event
|
* @param {MouseEvent} event
|
||||||
*/
|
*/
|
||||||
static #openEmbeddedDocument(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
|
const id = dataset.itemId ?? dataset.id
|
||||||
|
|
||||||
this.document.items.get(id).sheet.render(true)
|
this.document.items.get(id).sheet.render(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import {Profession} from "../documents/profession.mjs";
|
||||||
import {Culture} from "../documents/culture.mjs";
|
import {Culture} from "../documents/culture.mjs";
|
||||||
import {Species} from "../documents/species.mjs";
|
import {Species} from "../documents/species.mjs";
|
||||||
import {SpecialAbility} from "../documents/specialAbility.mjs";
|
import {SpecialAbility} from "../documents/specialAbility.mjs";
|
||||||
|
import {Equipment} from "../documents/equipment.mjs";
|
||||||
|
|
||||||
export class XmlImport {
|
export class XmlImport {
|
||||||
#months = [
|
#months = [
|
||||||
|
|
@ -199,9 +200,10 @@ export class XmlImport {
|
||||||
json.meta.titel = held.basis.rasse.aussehen.titel
|
json.meta.titel = held.basis.rasse.aussehen.titel
|
||||||
json.meta.stand = held.basis.rasse.aussehen.stand
|
json.meta.stand = held.basis.rasse.aussehen.stand
|
||||||
}
|
}
|
||||||
|
if (!options.skipAttributes) {
|
||||||
let attributes = held.eigenschaften.eigenschaft
|
let attributes = held.eigenschaften.eigenschaft
|
||||||
json.attribute = {}
|
json.attribute = {}
|
||||||
if (!options.skipAttributes) {
|
|
||||||
if (held.basis.gilde) {
|
if (held.basis.gilde) {
|
||||||
json.attribute.gilde = held.basis.gilde.name
|
json.attribute.gilde = held.basis.gilde.name
|
||||||
}
|
}
|
||||||
|
|
@ -235,7 +237,6 @@ export class XmlImport {
|
||||||
}
|
}
|
||||||
json.attribute.so = this.#getAttributeJson(attributes, "Sozialstatus")
|
json.attribute.so = this.#getAttributeJson(attributes, "Sozialstatus")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.skipAdvantages) this.#mapAdvantages(actor, held)
|
if (!options.skipAdvantages) this.#mapAdvantages(actor, held)
|
||||||
let specialAbilities = []
|
let specialAbilities = []
|
||||||
let liturgies = []
|
let liturgies = []
|
||||||
|
|
@ -291,6 +292,7 @@ export class XmlImport {
|
||||||
if (!options.skipSkills) this.#mapSkills(actor, held, combatValues)
|
if (!options.skipSkills) this.#mapSkills(actor, held, combatValues)
|
||||||
if (!options.skipSpells) this.#mapSpells(actor, held)
|
if (!options.skipSpells) this.#mapSpells(actor, held)
|
||||||
if (!options.skipLiturgies) this.#mapLiturgies(actor, liturgies)
|
if (!options.skipLiturgies) this.#mapLiturgies(actor, liturgies)
|
||||||
|
if (!options.skipEquipment) this.#mapEquipment(actor, held)
|
||||||
|
|
||||||
let notes = []
|
let notes = []
|
||||||
for (let note in held.kommentare) {
|
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) {
|
async #mapProfessions(actor, professions) {
|
||||||
if (actor.itemTypes["Profession"].length > 0) {
|
if (actor.itemTypes["Profession"].length > 0) {
|
||||||
actor.itemTypes["Profession"].forEach(p => {
|
actor.itemTypes["Profession"].forEach(p => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue