Repairs XML-Import for Advantages/Vornachteile
parent
b6814c9f74
commit
41045cb482
|
|
@ -86,6 +86,22 @@ async function addSkillFromCompendiumByNameToActor(talentName, taw, actor) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function addAdvantageFromCompendiumByNameToActor(advantageName, advantageValue, actor) {
|
||||||
|
const compendiumOfAdvantages = game.packs.get('DSA_4-1.Advantage');
|
||||||
|
const advantageId = compendiumOfAdvantages.index.find( skill => skill.name === advantageName)
|
||||||
|
if (advantageId) {
|
||||||
|
|
||||||
|
const advantage = await compendiumOfAdvantages.getDocument(advantageId._id);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const embeddedDocument = (await actor.createEmbeddedDocuments('Item', [advantage]))[0]
|
||||||
|
embeddedDocument.update({system: {value: advantageValue}});
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`${advantageName} not found in items`, error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets the text content of a file
|
* gets the text content of a file
|
||||||
* @param file the file with the desired content
|
* @param file the file with the desired content
|
||||||
|
|
@ -124,6 +140,13 @@ function mapSkills(actor, held) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mapAdvantages(actor, held) {
|
||||||
|
for (let advantage in held.vt.vorteil) {
|
||||||
|
advantage = held.vt.vorteil[advantage]
|
||||||
|
addAdvantageFromCompendiumByNameToActor(advantage.name, advantage.value, actor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* parses a json into a fitting character-json
|
* parses a json into a fitting character-json
|
||||||
* @param rawJson the json parsed from the Helden-Software XML
|
* @param rawJson the json parsed from the Helden-Software XML
|
||||||
|
|
@ -224,18 +247,7 @@ function mapRawJson(actor, rawJson) {
|
||||||
aktuell: attribute.value
|
aktuell: attribute.value
|
||||||
}
|
}
|
||||||
json.attribute.so = getAttributeJson(attributes, "Sozialstatus")
|
json.attribute.so = getAttributeJson(attributes, "Sozialstatus")
|
||||||
let benefits = []
|
mapAdvantages(actor, held)
|
||||||
for (let benefit in held.vt.vorteil) {
|
|
||||||
benefit = held.vt.vorteil[benefit]
|
|
||||||
let benefitJson = {
|
|
||||||
name: benefit.name,
|
|
||||||
}
|
|
||||||
if (benefit.value !== undefined) {
|
|
||||||
benefitJson.wert = benefit.value
|
|
||||||
}
|
|
||||||
benefits.push(benefitJson)
|
|
||||||
}
|
|
||||||
json.vornachteile = benefits
|
|
||||||
let specialAbilities = []
|
let specialAbilities = []
|
||||||
let liturgies = []
|
let liturgies = []
|
||||||
for (let specialAbility in held.sf.sonderfertigkeit) {
|
for (let specialAbility in held.sf.sonderfertigkeit) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue