diff --git a/src/main.mjs b/src/main.mjs index 020f549b..ffcfc7db 100644 --- a/src/main.mjs +++ b/src/main.mjs @@ -18,6 +18,7 @@ async function preloadHandlebarsTemplates() { return loadTemplates([ // ui partials. 'systems/DSA_4-1/templates/ui/partial-rollable-button.hbs', + 'systems/DSA_4-1/templates/ui/partial-rollable-weaponskill-button.hbs', 'systems/DSA_4-1/templates/ui/partial-attribute-button.hbs', 'systems/DSA_4-1/templates/ui/partial-talent-editable.hbs', 'systems/DSA_4-1/templates/ui/partial-die.hbs', diff --git a/src/module/data/character.mjs b/src/module/data/character.mjs index 8e4a2641..4ef55abd 100644 --- a/src/module/data/character.mjs +++ b/src/module/data/character.mjs @@ -39,12 +39,15 @@ export class PlayerCharacterDataModel extends foundry.abstract.TypeDataModel { mod: new NumberField({ required: true, integer: true }), }), aup: new SchemaField({ + aktuell: new NumberField({ required: true, integer: true, initial: 0 }), mod: new NumberField({ required: true, integer: true }), }), asp: new SchemaField({ + aktuell: new NumberField({ required: true, integer: true, initial: 0 }), mod: new NumberField({ required: true, integer: true }), }), kap: new SchemaField({ + aktuell: new NumberField({ required: true, integer: true, initial: 0 }), mod: new NumberField({ required: true, integer: true }), }), attribute: new SchemaField({ @@ -158,9 +161,6 @@ export class PlayerCharacterDataModel extends foundry.abstract.TypeDataModel { } _initializeSource(data, options) { - - - if (data.heldenausruestung.length === 0) { let sets = []; @@ -179,7 +179,6 @@ export class PlayerCharacterDataModel extends foundry.abstract.TypeDataModel { } - console.log(data) return super._initializeSource(data, options); } diff --git a/src/module/data/skill.mjs b/src/module/data/skill.mjs index 5032a4c1..c4903fd0 100644 --- a/src/module/data/skill.mjs +++ b/src/module/data/skill.mjs @@ -9,6 +9,8 @@ export class SkillDataModel extends BaseItem { name: new StringField({ required: true }), gruppe: new StringField({ required: true }), taw: new NumberField({ integer: true, initial: 0 }), + at: new NumberField({ required: false, integer: true, initial: 0 }), + pa: new NumberField({ required: false, integer: true, initial: 0 }), probe: new ArrayField(new StringField(), { exact: 3 }), // References one of the eight attributes by name voraussetzung: new SchemaField({ talent: new StringField({ model: SkillDataModel }), diff --git a/src/module/documents/character.mjs b/src/module/documents/character.mjs index de14b377..b2de8c3a 100644 --- a/src/module/documents/character.mjs +++ b/src/module/documents/character.mjs @@ -38,16 +38,16 @@ export class Character extends Actor { const kk = systemData.attribute.kk.aktuell; - systemData.lep.max = (ko + ko + kk) / 2 + systemData.lep.mod; - systemData.aup.max = (mu + ko + ge) / 2 + systemData.aup.mod; - systemData.asp.aktuell = (mu + _in + ch) / 2 + systemData.asp.mod; + systemData.lep.max = Math.round((ko + ko + kk) / 2) + systemData.lep.mod; + systemData.aup.max = Math.round((mu + ko + ge) / 2) + systemData.aup.mod; + systemData.asp.max = Math.round((mu + _in + ch) / 2) + systemData.asp.mod; - systemData.at = (mu + ge + kk) / 5; - systemData.pa = (_in + ge + kk) / 5; - systemData.fk = (_in + ff + kk) / 5; + systemData.at = Math.round((mu + ge + kk) / 5); + systemData.pa = Math.round((_in + ge + kk) / 5); + systemData.fk = Math.round((_in + ff + kk) / 5); - systemData.ini.aktuell = (mu + mu + _in + ge) / 5 + systemData.ini.mod; - systemData.mr.aktuell = (mu + kl + ko) / 5 + systemData.mr.mod; + systemData.ini.aktuell = Math.round((mu + mu + _in + ge) / 5) + systemData.ini.mod; + systemData.mr.aktuell = Math.round((mu + kl + ko) / 5) + systemData.mr.mod; } diff --git a/src/module/sheets/characterSheet.mjs b/src/module/sheets/characterSheet.mjs index 7035b618..cb3ca60d 100644 --- a/src/module/sheets/characterSheet.mjs +++ b/src/module/sheets/characterSheet.mjs @@ -24,9 +24,10 @@ export class CharacterSheet extends ActorSheet { } /** @override */ - getData() { + async getData() { const context = super.getData(); + // Use a safe clone of the actor data for further operations. const actorData = context.data; @@ -38,8 +39,7 @@ export class CharacterSheet extends ActorSheet { this.#addAdvantagesToContext(context) this.#addAttributesToContext(context) this.#addEquipmentsToContext(context) - this.#addCombatStatistics(context) - + await this.#addCombatStatistics(context) return context; } @@ -75,6 +75,8 @@ export class CharacterSheet extends ActorSheet { eigenschaft2: werte[1].name, eigenschaft3: werte[2].name, probe: `(${eigenschaften.join("/")})`, + at: item.system.at, + pa: item.system.pa, id: item._id, }; context.skills[talentGruppe].push(obj); @@ -171,13 +173,76 @@ export class CharacterSheet extends ActorSheet { return false } - #addCombatStatistics(context) { + #findEquipmentOnSlot(slot, setNumber) { + return this.object.items.get(this.object.system.heldenausruestung[setNumber][slot]) + } + + #findTalentsOfEquipment(equipment) { + + } + + async #addCombatStatistics(context) { const actorData = context.data; + context.inidice = actorData.system.ini.wuerfel; context.inivalue = actorData.system.ini.aktuell; context.inimod = actorData.system.ini.mod; + context.aupper = Math.min((context.actor.system.aup.aktuell / context.actor.system.aup.max) * 100, 100); + context.lepper = Math.min((context.actor.system.lep.aktuell / context.actor.system.lep.max) * 100, 100); + context.lepcurrent = context.actor.system.lep.aktuell ?? 0 + context.aupcurrent = context.actor.system.aup.aktuell ?? 0 + + const fernkampf = this.#findEquipmentOnSlot("fernkampf", 0) + const links = this.#findEquipmentOnSlot("links", 0) + const rechts = this.#findEquipmentOnSlot("rechts", 0) + context.attacks = []; + + if (fernkampf) { + const fkitems = fernkampf.system.rangedSkills.map( async (skillInQuestion) => await this.object.items.getName(skillInQuestion) ) + fkitems.forEach( async skill => { + const obj = await skill + console.log(this.object.system.fk, obj.system.at); + context.attacks.push({ + name: obj.name, + using: fernkampf.name, + atroll: `1d20 + ${this.object.system.fk + obj.system.at}`, + at: `1w20 + ${this.object.system.fk + obj.system.at}`, + }) + }) + } + if (links) { + const meitems = links.system.meleeSkills.map( async (skillInQuestion) => await this.object.items.getName(skillInQuestion) ) + meitems.forEach( async skill => { + const obj = await skill + context.attacks.push({ + name: obj.name, + using: links.name, + atroll: `1d20 + ${this.object.system.at + obj.system.at + links.system.attackModifier}`, + at: `1w20 + ${this.object.system.at + obj.system.at + links.system.attackModifier}`, + paroll: `1d20 + ${this.object.system.pa + obj.system.pa + links.system.parryModifier}`, + pa: `1w20 + ${this.object.system.pa + obj.system.pa + links.system.parryModifier}`, + }) + }) + } + if (rechts) { + const meitems = rechts.system.meleeSkills.map( async (skillInQuestion) => await this.object.items.getName(skillInQuestion) ) + meitems.forEach( async skill => { + const obj = await skill + console.log(this.object.system.at) + context.attacks.push({ + name: obj.name, + using: rechts.name, + atroll: `1d20 + ${this.object.system.at + obj.system.at + rechts.system.attackModifier}`, + at: `1w20 + ${this.object.system.at + obj.system.at + rechts.system.attackModifier}`, + paroll: `1d20 + ${this.object.system.pa + obj.system.pa + rechts.system.parryModifier}`, + pa: `1w20 + ${this.object.system.pa + obj.system.pa + rechts.system.parryModifier}`, + }) + }) + } + + // add weapons to sidebar } #addEquipmentsToContext(context) { @@ -289,7 +354,11 @@ export class CharacterSheet extends ActorSheet { } prepareEigenschaftRoll(actorData, name) { - return actorData.system.attribute[name.toLowerCase()].aktuell + if (name) { + return actorData.system.attribute[name.toLowerCase()].aktuell + } else { + return 0 + } } async _onTalentRoll(event) { diff --git a/src/module/xml-import/xml-import.mjs b/src/module/xml-import/xml-import.mjs index b9cbb5ae..ec8fdd2a 100644 --- a/src/module/xml-import/xml-import.mjs +++ b/src/module/xml-import/xml-import.mjs @@ -222,25 +222,6 @@ function mapRawJson(actor, rawJson) { mod: filterAttribute(attributes,"Karmaenergie").mod } let attribute = filterAttribute(attributes,"Karmaenergie") - json.attribute.at = { - mod: attribute.mod, - aktuell: attribute.value - } - attribute = filterAttribute(attributes,"at") - json.attribute.pa = { - mod: attribute.mod, - aktuell: attribute.value - } - attribute = filterAttribute(attributes,"pa") - json.attribute.at = { - mod: attribute.mod, - aktuell: attribute.value - } - attribute = filterAttribute(attributes,"fk") - json.attribute.fk = { - mod: attribute.mod, - aktuell: attribute.value - } attribute = filterAttribute(attributes,"ini") json.ini = { mod: attribute.mod, diff --git a/src/packs/__source/talente-brw/kampf/bogen.json b/src/packs/__source/talente-brw/kampf/bogen.json new file mode 100644 index 00000000..34e68e6c --- /dev/null +++ b/src/packs/__source/talente-brw/kampf/bogen.json @@ -0,0 +1,10 @@ +{ + "_id": "Msv0BWdwlNlF2ETU", + "_key": "!items!Msv0BWdwlNlF2ETU", + "type": "Skill", + "name": "Bogen", + "system": { + "gruppe": "Kampf", + "talent": "" + } +} diff --git a/src/packs/__source/talente-brw/kampf/dolche.json b/src/packs/__source/talente-brw/kampf/dolche.json new file mode 100644 index 00000000..9294bcf1 --- /dev/null +++ b/src/packs/__source/talente-brw/kampf/dolche.json @@ -0,0 +1,10 @@ +{ + "_id": "Msv0BWdwlNlF2EtU", + "_key": "!items!Msv0BWdwlNlF2EtU", + "type": "Skill", + "name": "Dolche", + "system": { + "gruppe": "Kampf", + "talent": "" + } +} diff --git a/src/packs/__source/talente-brw/kampf/schwerter.json b/src/packs/__source/talente-brw/kampf/schwerter.json new file mode 100644 index 00000000..6c6f1814 --- /dev/null +++ b/src/packs/__source/talente-brw/kampf/schwerter.json @@ -0,0 +1,10 @@ +{ + "_id": "Msv0bWdwlNlF2EtU", + "_key": "!items!Msv0bWdwlNlF2EtU", + "type": "Skill", + "name": "Schwerter", + "system": { + "gruppe": "Kampf", + "talent": "" + } +} diff --git a/src/packs/__source/talente-brw/kampf/säbel.json b/src/packs/__source/talente-brw/kampf/säbel.json new file mode 100644 index 00000000..057d3833 --- /dev/null +++ b/src/packs/__source/talente-brw/kampf/säbel.json @@ -0,0 +1,10 @@ +{ + "_id": "Msv0bWdwlNlF2etU", + "_key": "!items!Msv0bWdwlNlF2etU", + "type": "Skill", + "name": "Säbel", + "system": { + "gruppe": "Kampf", + "talent": "" + } +} diff --git a/src/style/_rollable.scss b/src/style/_rollable.scss index d0e71cf2..0516e708 100644 --- a/src/style/_rollable.scss +++ b/src/style/_rollable.scss @@ -13,7 +13,7 @@ $rollable_colours: ( "Wissen": colour.$talent-knowledge-color, "Sprachen": colour.$talent-language-color, "Handwerk": colour.$talent-crafting-color, - "kampftalent": colour.$kampftalent-color, + "kampf": colour.$kampftalent-color, "liturgie": colour.$liturgie-color, "zauber": colour.$zauber-color, ); @@ -197,7 +197,7 @@ $rollable_colours: ( @include coloring("liturgie"); @include coloring("zauber"); @include coloring("talent"); -@include coloring("kampftalent"); +@include coloring("kampf"); @include coloring("Körperlich"); @include coloring("Natur"); @@ -205,3 +205,4 @@ $rollable_colours: ( @include coloring("Wissen"); @include coloring("Sprachen"); @include coloring("Handwerk"); + diff --git a/src/templates/actor/actor-character-sheet.hbs b/src/templates/actor/actor-character-sheet.hbs index 17fddb78..ff554b0a 100644 --- a/src/templates/actor/actor-character-sheet.hbs +++ b/src/templates/actor/actor-character-sheet.hbs @@ -18,19 +18,27 @@