imports combatstatistics
parent
4388cc8f60
commit
8b0e11f071
|
|
@ -10,7 +10,7 @@ export class SkillDataModel extends BaseItem {
|
||||||
gruppe: new StringField({required: true}),
|
gruppe: new StringField({required: true}),
|
||||||
taw: new NumberField({integer: true, initial: 0}),
|
taw: new NumberField({integer: true, initial: 0}),
|
||||||
at: new NumberField({required: false, integer: true, initial: 0}),
|
at: new NumberField({required: false, integer: true, initial: 0}),
|
||||||
pa: new NumberField({required: false, integer: true, initial: 0}),
|
pa: new NumberField({required: false, integer: true, nullable: true, initial: 0}),
|
||||||
probe: new ArrayField(new StringField(), {exact: 3}), // References one of the eight attributes by name
|
probe: new ArrayField(new StringField(), {exact: 3}), // References one of the eight attributes by name
|
||||||
voraussetzung: new SchemaField({
|
voraussetzung: new SchemaField({
|
||||||
talent: new StringField({model: SkillDataModel}),
|
talent: new StringField({model: SkillDataModel}),
|
||||||
|
|
|
||||||
|
|
@ -94,10 +94,22 @@ export class CharacterSheet extends ActorSheet {
|
||||||
eigenschaft2: werte[1].name,
|
eigenschaft2: werte[1].name,
|
||||||
eigenschaft3: werte[2].name,
|
eigenschaft3: werte[2].name,
|
||||||
probe: `(${eigenschaften.join("/")})`,
|
probe: `(${eigenschaften.join("/")})`,
|
||||||
|
id: item._id,
|
||||||
at: item.system.at,
|
at: item.system.at,
|
||||||
pa: item.system.pa,
|
pa: item.system.pa,
|
||||||
id: item._id,
|
komplexität: item.system.komplexität
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (talentGruppe === "Kampf") {
|
||||||
|
|
||||||
|
if (item.system.pa != null) { // has no parry value so it must be ranged talent (TODO: but it isnt as there can be combatstatistics which has no pa value assigned to)
|
||||||
|
obj.at = item.system.at + context.derived.at.aktuell
|
||||||
|
obj.pa = item.system.pa + context.derived.pa.aktuell
|
||||||
|
} else {
|
||||||
|
obj.at = item.system.at + context.derived.fk.aktuell
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
context.skills[talentGruppe].push(obj);
|
context.skills[talentGruppe].push(obj);
|
||||||
context.flatSkills.push(obj);
|
context.flatSkills.push(obj);
|
||||||
}
|
}
|
||||||
|
|
@ -379,7 +391,6 @@ export class CharacterSheet extends ActorSheet {
|
||||||
const fkitems = fernkampf.system.rangedSkills.map(async (skillInQuestion) => await this.object.items.getName(skillInQuestion))
|
const fkitems = fernkampf.system.rangedSkills.map(async (skillInQuestion) => await this.object.items.getName(skillInQuestion))
|
||||||
fkitems.forEach(async skill => {
|
fkitems.forEach(async skill => {
|
||||||
const obj = await skill
|
const obj = await skill
|
||||||
console.log(this.object.system.fk, obj.system.at);
|
|
||||||
context.attacks.push({
|
context.attacks.push({
|
||||||
name: obj.name,
|
name: obj.name,
|
||||||
using: fernkampf.name,
|
using: fernkampf.name,
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ function getJsonFromXML(dom) {
|
||||||
return jsonResult;
|
return jsonResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addSkillFromCompendiumByNameToActor(talentName, taw, actor) {
|
async function addSkillFromCompendiumByNameToActor(talentName, taw, actor, combatStatistics, attributes) {
|
||||||
const compendiumOfSkills = game.packs.get('DSA_4-1.talente');
|
const compendiumOfSkills = game.packs.get('DSA_4-1.talente');
|
||||||
const talentId = compendiumOfSkills.index.find(skill => skill.name === talentName)
|
const talentId = compendiumOfSkills.index.find(skill => skill.name === talentName)
|
||||||
if (talentId) {
|
if (talentId) {
|
||||||
|
|
@ -83,7 +83,21 @@ async function addSkillFromCompendiumByNameToActor(talentName, taw, actor) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const embeddedDocument = (await actor.createEmbeddedDocuments('Item', [talent]))[0]
|
const embeddedDocument = (await actor.createEmbeddedDocuments('Item', [talent]))[0]
|
||||||
embeddedDocument.update({system: {taw: taw}});
|
if (talent.system.gruppe === "Kampf") {
|
||||||
|
const atbasis = attributes.find(p => p.name === "at").value
|
||||||
|
const pabasis = attributes.find(p => p.name === "pa").value
|
||||||
|
const combatStatistic = combatStatistics.find(p => p.name === talent.name)
|
||||||
|
if (combatStatistic) { // melee with AT/PA values
|
||||||
|
let at = combatStatistic.at - atbasis ?? 0
|
||||||
|
let pa = combatStatistic.pa - pabasis ?? 0
|
||||||
|
console.log({system: {taw, at, pa}})
|
||||||
|
embeddedDocument.update({system: {taw, at, pa}});
|
||||||
|
} else { // ranged with only AT values which is equal to taw
|
||||||
|
embeddedDocument.update({system: {taw: taw, at: taw, pa: null}}); // at is already at raw taw and wasn't influenced by helden-software precalculations
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
embeddedDocument.update({system: {taw: taw, at: null, pa: null}}); // just regular talent with taw
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`${talentName} not found in items`, error)
|
console.error(`${talentName} not found in items`, error)
|
||||||
}
|
}
|
||||||
|
|
@ -171,7 +185,7 @@ function calculateBirthdate(json) {
|
||||||
return `${day}. ${month} ${year} BF`
|
return `${day}. ${month} ${year} BF`
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapSkills(actor, held) {
|
function mapSkills(actor, held, kampfwerte) {
|
||||||
for (let talent in held.talentliste.talent) {
|
for (let talent in held.talentliste.talent) {
|
||||||
talent = held.talentliste.talent[talent]
|
talent = held.talentliste.talent[talent]
|
||||||
|
|
||||||
|
|
@ -191,7 +205,8 @@ function mapSkills(actor, held) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// proceed
|
// proceed
|
||||||
addSkillFromCompendiumByNameToActor(talent.name, talent.value, actor)
|
const eigenschaften = held.eigenschaften.eigenschaft
|
||||||
|
addSkillFromCompendiumByNameToActor(talent.name, talent.value, actor, kampfwerte, eigenschaften)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -333,10 +348,6 @@ function mapRawJson(actor, rawJson) {
|
||||||
json.sonderfertigkeiten = specialAbilities
|
json.sonderfertigkeiten = specialAbilities
|
||||||
json.liturgien = liturgies
|
json.liturgien = liturgies
|
||||||
|
|
||||||
mapSkills(actor, held)
|
|
||||||
mapSpells(actor, held)
|
|
||||||
mapMiracles(actor, liturgies)
|
|
||||||
|
|
||||||
let combatValues = []
|
let combatValues = []
|
||||||
for (let combatValue in held.kampf.kampfwerte) {
|
for (let combatValue in held.kampf.kampfwerte) {
|
||||||
combatValue = held.kampf.kampfwerte[combatValue]
|
combatValue = held.kampf.kampfwerte[combatValue]
|
||||||
|
|
@ -347,6 +358,11 @@ function mapRawJson(actor, rawJson) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
json.kampfwerte = combatValues
|
json.kampfwerte = combatValues
|
||||||
|
|
||||||
|
mapSkills(actor, held, combatValues)
|
||||||
|
mapSpells(actor, held)
|
||||||
|
mapMiracles(actor, liturgies)
|
||||||
|
|
||||||
let notes = []
|
let notes = []
|
||||||
for (let note in held.kommentare) {
|
for (let note in held.kommentare) {
|
||||||
note = held.kommentare[note]
|
note = held.kommentare[note]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue