From 34c702419179880cfab8553670fc242887d16952 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Tue, 10 May 2022 23:04:04 +0200 Subject: [PATCH] Advantage! --- module/actor/actor.js | 8 ++++---- module/controllers/bol-rolls.js | 5 +++-- module/system/bol-utility.js | 18 +++++++++--------- system.json | 2 +- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/module/actor/actor.js b/module/actor/actor.js index 1e5c549..429612d 100644 --- a/module/actor/actor.js +++ b/module/actor/actor.js @@ -589,7 +589,7 @@ export class BoLActor extends Actor { if (!protect.data.properties.soak.formula || protect.data.properties.soak.formula == "") { ui.notifications.warn(`L'armure ${protect.name} n'a pas de formule pour la protection !`) } else { - formula += "+" + protect.data.properties.soak.formula + formula += "+" + " max(" + protect.data.properties.soak.formula +",0)" } } else { if (protect.data.properties.soak.value == undefined) { @@ -608,9 +608,9 @@ export class BoLActor extends Actor { rollProtection(itemId) { let armor = this.data.items.get(itemId) if (armor) { - let armorFormula = armor.data.data.properties.soak.formula; + let armorFormula = "max("+armor.data.data.properties.soak.formula + ", 0)" let rollArmor = new Roll(armorFormula) - rollArmor.roll({ async: false }).toMessage(); + rollArmor.roll({ async: false }).toMessage() } } @@ -618,7 +618,7 @@ export class BoLActor extends Actor { rollWeaponDamage(itemId) { let weapon = this.data.items.get(itemId) if (weapon) { - let r = new BoLDefaultRoll({ id: randomID(16), isSuccess: true, mode: "weapon", weapon: weapon, actor: this }) + let r = new BoLDefaultRoll({ id: randomID(16), isSuccess: true, mode: "weapon", weapon: weapon, actorId: this.id, actor: this }) r.setSuccess(true) r.rollDamage() } diff --git a/module/controllers/bol-rolls.js b/module/controllers/bol-rolls.js index 15a41ed..0b456cd 100644 --- a/module/controllers/bol-rolls.js +++ b/module/controllers/bol-rolls.js @@ -555,9 +555,10 @@ export class BoLDefaultRoll { } /* -------------------------------------------- */ - getDamageAttributeValue(attrDamage) { + getDamageAttributeValue(attrDamage, actorId = undefined) { let attrDamageValue = 0 - let actor = game.actors.get( this.rollData.actorId) + + let actor = game.actors.get( (actorId) ? actorId: this.rollData.actorId) if (attrDamage.includes("vigor")) { attrDamageValue = actor.data.data.attributes.vigor.value if (attrDamage.includes("half")) { diff --git a/module/system/bol-utility.js b/module/system/bol-utility.js index ed18c47..9f92bcf 100644 --- a/module/system/bol-utility.js +++ b/module/system/bol-utility.js @@ -274,16 +274,16 @@ export class BoLUtility { defender.sufferDamage(attackDef.finalDamage); } if (defenseMode == 'hero-reduce-damage') { - let armorFormula = defender.getArmorFormula(); + let armorFormula = defender.getArmorFormula() attackDef.rollArmor = new Roll(armorFormula) - attackDef.rollArmor.roll({ async: false }); - attackDef.armorProtect = (attackDef.rollArmor.total < 0) ? 0 : attackDef.rollArmor.total; - attackDef.rollHero = new Roll("1d6"); - attackDef.rollHero.roll({ async: false }); - attackDef.finalDamage = attackDef.damageRoll.total - attackDef.rollHero.total - attackDef.armorProtect; - attackDef.finalDamage = (attackDef.finalDamage < 0) ? 0 : attackDef.finalDamage; - defender.sufferDamage(attackDef.finalDamage); - defender.subHeroPoints(1); + attackDef.rollArmor.roll({ async: false }) + attackDef.armorProtect = (attackDef.rollArmor.total < 0) ? 0 : attackDef.rollArmor.total + attackDef.rollHero = new Roll("1d6") + attackDef.rollHero.roll({ async: false }) + attackDef.finalDamage = attackDef.damageRoll.total - attackDef.rollHero.total - attackDef.armorProtect + attackDef.finalDamage = (attackDef.finalDamage < 0) ? 0 : attackDef.finalDamage + defender.sufferDamage(attackDef.finalDamage) + defender.subHeroPoints(1) } if (defenseMode == 'hero-in-extremis') { attackDef.finalDamage = 0; diff --git a/system.json b/system.json index 437bdf5..0707422 100644 --- a/system.json +++ b/system.json @@ -14,7 +14,7 @@ "url": "https://github.com/ZigmundKreud/bol", "license": "LICENSE.txt", "flags": {}, - "version": "1.3.6", + "version": "1.3.7", "templateVersion": 10, "minimumCoreVersion": "0.8.6", "compatibleCoreVersion": "9",