From 3e50a9135f80d609b9306fccf42b7c277d3a26e6 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Mon, 23 May 2022 18:38:51 +0200 Subject: [PATCH] Various fixes --- module/actor/actor.js | 14 +++++++++++--- module/controllers/bol-rolls.js | 22 ++++++++++++++-------- module/system/bol-utility.js | 6 ++++-- system.json | 2 +- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/module/actor/actor.js b/module/actor/actor.js index 58881dc..a9a891c 100644 --- a/module/actor/actor.js +++ b/module/actor/actor.js @@ -212,6 +212,9 @@ export class BoLActor extends Actor { get fightoptions() { return this.itemData.filter(i => i.type === "feature" && i.data.subtype === "fightoption") } + get godsfaith() { + return this.itemData.filter(i => i.type === "feature" && i.data.subtype === "godsfaith") + } get features() { return this.itemData.filter(i => i.type === "feature") } @@ -440,6 +443,11 @@ export class BoLActor extends Actor { "label": "BOL.featureCategory.fightoptions", "ranked": false, "items": this.fightoptions + }, + "godsfaith": { + "label": "BOL.featureSubtypes.gods", + "ranked": false, + "items": this.godsfaith } } } @@ -535,7 +543,7 @@ export class BoLActor extends Actor { /*-------------------------------------------- */ buildListeActions() { - return this.melee.concat(this.ranged) + return this.melee.concat(this.ranged).concat(this.natural) } /*-------------------------------------------- */ @@ -573,8 +581,8 @@ export class BoLActor extends Actor { /*-------------------------------------------- */ async sufferDamage(damage) { - let newHP = this.data.data.resources.hp.value - damage; - await this.update({ 'data.resources.hp.value': newHP }); + let newHP = this.data.data.resources.hp.value - damage + await this.update({ 'data.resources.hp.value': newHP }) } /* -------------------------------------------- */ diff --git a/module/controllers/bol-rolls.js b/module/controllers/bol-rolls.js index 8490c43..3bca815 100644 --- a/module/controllers/bol-rolls.js +++ b/module/controllers/bol-rolls.js @@ -314,12 +314,12 @@ export class BoLRoll { }) html.find('#boon').change((event) => { let boons = $('#boon').val() - this.rollData.nbBoons = (!boons || boons.length == 0) ? 0 : Math.max(...boons.map(i => parseInt(i))) + this.rollData.nbBoons = (!boons || boons.length == 0) ? 0 : boons.length this.updateTotalDice() }) html.find('#flaw').change((event) => { let flaws = $('#flaw').val() - this.rollData.nbFlaws = (!flaws || flaws.length == 0) ? 0 : Math.max(...flaws.map(i => parseInt(i))) + this.rollData.nbFlaws = (!flaws || flaws.length == 0) ? 0 : flaws.length this.updateTotalDice() }) html.find('.bdice').click((event) => { @@ -335,15 +335,15 @@ export class BoLRoll { } /* -------------------------------------------- */ - static preProcessWeapon(rollData) { + static preProcessWeapon(rollData, defender) { if (rollData.mode == "weapon") { rollData.weaponModifier = rollData.weapon.data.data.properties.attackModifiers ?? 0; rollData.attackBonusDice = rollData.weapon.data.data.properties.attackBonusDice - if (rollData.defender) { // If target is selected - rollData.defence = rollData.defender.defenseValue - rollData.armorMalus = rollData.defender.armorMalusValue + if (defender) { // If target is selected + rollData.defence = defender.defenseValue + rollData.armorMalus = defender.armorMalusValue rollData.shieldBlock = 'none' - let shields = rollData.defender.shields + let shields = defender.shields for (let shield of shields) { rollData.shieldBlock = (shield.data.properties.blocking.blockingAll) ? 'blockall' : 'blockone'; rollData.shieldAttackMalus = (shield.data.properties.blocking.malus) ? shield.data.properties.blocking.malus : 1; @@ -361,6 +361,12 @@ export class BoLRoll { const rollOptionTpl = `systems/bol/templates/dialogs/${rollData.mode}-roll-dialog.hbs` let actor = game.actors.get( rollData.actorId ) + let defender + if ( rollData.targetId) { + let token = game.scenes.current.tokens.get(rollData.targetId) + defender = token.actor + } + rollData.careers = actor.careers rollData.boons = actor.bonusBoons rollData.flaws = actor.malusFlaws @@ -386,7 +392,7 @@ export class BoLRoll { rollData.attackBonusDice = false rollData.armorMalus = 0 // Specific stuff - this.preProcessWeapon(rollData) + this.preProcessWeapon(rollData, defender) this.preProcessFightOption(rollData) this.updateArmorMalus(rollData) this.updatePPCost(rollData) diff --git a/module/system/bol-utility.js b/module/system/bol-utility.js index 9f92bcf..1ce42df 100644 --- a/module/system/bol-utility.js +++ b/module/system/bol-utility.js @@ -256,8 +256,9 @@ export class BoLUtility { return } // ?? Why ??? attackDef.defenseDone = true - attackDef.defenseMode = defenseMode; - let defender = game.actors.get(attackDef.defenderId) + attackDef.defenseMode = defenseMode + let token = game.scenes.current.tokens.get(attackDef.targetId) + let defender = token.actor if (defenseMode == 'damage-with-armor') { let armorFormula = defender.getArmorFormula() @@ -300,6 +301,7 @@ export class BoLUtility { rollHero: attackDef.rollHero, weaponHero: attackDef.weaponHero, armorProtect: attackDef.armorProtect, + name: defender.name, defender: defender, defenseMode: attackDef.defenseMode, finalDamage: attackDef.finalDamage diff --git a/system.json b/system.json index 25d3fdf..9962ee1 100644 --- a/system.json +++ b/system.json @@ -14,7 +14,7 @@ "url": "https://github.com/ZigmundKreud/bol", "license": "LICENSE.txt", "flags": {}, - "version": "1.3.19", + "version": "1.3.20", "templateVersion": 10, "minimumCoreVersion": "0.8.6", "compatibleCoreVersion": "9",