ironed out last bugs

pull/13/head
Jendrik 2025-09-26 00:20:00 +02:00
parent 646c9c6d16
commit 41de33cef3
3 changed files with 57 additions and 34 deletions

View File

@ -11,16 +11,4 @@ Hooks.once("init", () => {
};
console.log("DSA 4.1 is ready for development!")
})
Hooks.on("getActorContextOptions", (application, menuItems) => {
menuItems.push({
name: "Import from XML",
icon: '<i class="fas fa-file"></i>',
callback: (li) => {
const actorId = li.getAttribute("data-entry-id")
const actor = game.actors.get(actorId)
actor.import()
}
})
})

View File

@ -104,7 +104,7 @@ export class PlayerCharacterDataModel extends foundry.abstract.TypeDataModel {
}),
vornachteile: new ArrayField(new SchemaField({
name: new StringField(),
value: new NumberField(),
wert: new NumberField({ required: false, integer: true }),
})),
sonderfertigkeiten: new ArrayField(new SchemaField({
name: new StringField(),
@ -114,7 +114,7 @@ export class PlayerCharacterDataModel extends foundry.abstract.TypeDataModel {
name: new StringField(),
taw: new NumberField({required: true, integer: true }),
probe: new StringField(),
be: new NumberField({required: false, integer: true }),
be: new StringField({required: false }),
komplexitaet: new NumberField({required: false, integer: true }),
})),
zauber: new ArrayField(new SchemaField({
@ -123,7 +123,7 @@ export class PlayerCharacterDataModel extends foundry.abstract.TypeDataModel {
hauszauber: new BooleanField(),
zfw: new NumberField({ required: true, integer: true }),
anmerkungen: new StringField(),
komplexitaet: new NumberField({required: true, integer: true }),
komplexitaet: new StringField({required: true }),
})),
liturgien: new ArrayField(new SchemaField({
name: new StringField(),

View File

@ -123,21 +123,21 @@ function mapRawJson(rawJson) {
let professionString = profession.string
professions.push(professionString)
}
json.meta.profession = professions
json.geschlecht = held.basis.geschlecht.name
json.haarfarbe = held.basis.rasse.aussehen.haarfarbe
json.groesse = held.basis.rasse.groesse.value
json.augenfarbe = held.basis.rasse.aussehen.augenfarbe
json.geburtstag = calculateBirthdate(held.basis.rasse.aussehen)
json.alter = held.basis.rasse.aussehen.alter
json.gewicht = held.basis.rasse.groesse.gewicht
json.aussehen = [
json.meta.professions = professions
json.meta.geschlecht = held.basis.geschlecht.name
json.meta.haarfarbe = held.basis.rasse.aussehen.haarfarbe
json.meta.groesse = held.basis.rasse.groesse.value
json.meta.augenfarbe = held.basis.rasse.aussehen.augenfarbe
json.meta.geburtstag = calculateBirthdate(held.basis.rasse.aussehen)
json.meta.alter = held.basis.rasse.aussehen.alter
json.meta.gewicht = held.basis.rasse.groesse.gewicht
json.meta.aussehen = [
held.basis.rasse.aussehen.aussehentext0,
held.basis.rasse.aussehen.aussehentext1,
held.basis.rasse.aussehen.aussehentext2,
held.basis.rasse.aussehen.aussehentext3,
]
json.familie = [
json.meta.familie = [
held.basis.rasse.aussehen.familietext0,
held.basis.rasse.aussehen.familietext1,
held.basis.rasse.aussehen.familietext2,
@ -145,10 +145,13 @@ function mapRawJson(rawJson) {
held.basis.rasse.aussehen.familietext4,
held.basis.rasse.aussehen.familietext5,
]
json.titel = held.basis.rasse.aussehen.titel
json.stand = held.basis.rasse.aussehen.stand
json.meta.titel = held.basis.rasse.aussehen.titel
json.meta.stand = held.basis.rasse.aussehen.stand
let attributes = held.eigenschaften.eigenschaft
json.attribute = {}
if (held.basis.gilde) {
json.attribute.gilde = held.basis.gilde.name
}
json.attribute.mu = getAttributeJson(attributes, "Mut")
json.attribute.kl = getAttributeJson(attributes, "Klugheit")
json.attribute.in = getAttributeJson(attributes, "Intuition")
@ -198,6 +201,18 @@ function mapRawJson(rawJson) {
aktuell: attribute.value
}
json.attribute.so = getAttributeJson(attributes, "Sozialstatus")
let benefits = []
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 liturgies = []
for (let specialAbility in held.sf.sonderfertigkeit) {
@ -236,13 +251,18 @@ function mapRawJson(rawJson) {
let talents = []
for (let talent in held.talentliste.talent) {
talent = held.talentliste.talent[talent]
talents.push({
let talentJson = {
name: talent.name,
taw: talent.value,
probe: talent.probe.trim(),
be: talent.be,
komplexitaet: talent.k,
})
}
if (talent.be !== undefined) {
talentJson.be = talent.be
}
if (talent.k !== undefined) {
talentJson.komplexitaet = parseInt(talent.k)
}
talents.push(talentJson)
}
json.talente = talents
let spells = []
@ -280,7 +300,10 @@ function mapRawJson(rawJson) {
}
json.notizen = notes
return json
return {
name: held.name,
system: json,
}
}
/**
@ -305,5 +328,17 @@ function getAttributeJson(attributes, name) {
* @returns {{}} the json of the desired attribute
*/
function filterAttribute(attributes, name) {
return attributes.filter(attribute => attribute.name === name)
}
return attributes.filter(attribute => attribute.name === name)[0]
}
Hooks.on("getActorContextOptions", (application, menuItems) => {
menuItems.push({
name: "Import from XML",
icon: '<i class="fas fa-file"></i>',
callback: (li) => {
const actorId = li.getAttribute("data-entry-id")
const actor = game.actors.get(actorId)
actor.import()
}
})
})