From 0d599d41f9b8458bb53097049e8cc33400b11261 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 14 Jan 2021 00:35:55 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20parade=20cr=C3=A9atures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor.js | 13 +++++++++---- module/item-arme.js | 2 +- module/item-competencecreature.js | 2 +- module/rdd-combat.js | 14 ++++++++------ 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/module/actor.js b/module/actor.js index df3afb1d..b45b03e9 100644 --- a/module/actor.js +++ b/module/actor.js @@ -2119,10 +2119,10 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async rollCompetenceCreature(compName) { - let competence = this.getCompetence(compName); + const competence = this.getCompetence(compName); if (competence.type == 'competencecreature' && competence.data.iscombat) { - let competence = this.getCompetence(compName); - RdDCombat.createUsingTarget(this).attaque(competence, armeItem); + const arme = RdDItemCompetenceCreature.toArme(competence); + RdDCombat.createUsingTarget(this).attaque(competence, arme); } else { this.rollCompetence(competence.name); @@ -2131,7 +2131,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ rollArme(compName, armeName = undefined) { - let arme = this.data.items.find(item => item.name == armeName && RdDItemArme.isArme(item)); + let arme = armeName ? this.data.items.find(item => item.name == armeName && RdDItemArme.isArme(item)) : undefined; let competence = this.getCompetence(compName); if (arme || armeName || (competence.type == 'competencecreature' && competence.data.iscombat)) { @@ -2151,6 +2151,11 @@ export class RdDActor extends Actor { return undefined; } + getArmeParade(armeParadeId) { + const item = armeParadeId ? this.getOwnedItem(armeParadeId) : undefined; + return RdDItemArme.getArmeData(item); + } + /* -------------------------------------------- */ async equiperObjet(itemID) { let item = this.getOwnedItem(itemID); diff --git a/module/item-arme.js b/module/item-arme.js index 642139d2..72a9eed0 100644 --- a/module/item-arme.js +++ b/module/item-arme.js @@ -25,7 +25,7 @@ export class RdDItemArme extends Item { switch (item ? item.data.type : '') { case 'arme': return item.data; case 'competencecreature': - return RdDItemCompetenceCreature.toArme(item); + return RdDItemCompetenceCreature.toArme(item.data); } return RdDItemArme.mainsNues(); } diff --git a/module/item-competencecreature.js b/module/item-competencecreature.js index 73c58ef1..5d3235a4 100644 --- a/module/item-competencecreature.js +++ b/module/item-competencecreature.js @@ -10,7 +10,7 @@ export class RdDItemCompetenceCreature extends Item { rollData.competence.data.categorie = "creature"; rollData.selectedCarac = rollData.carac.carac_creature; if (rollData.competence.data.iscombat) { - rollData.arme = RdDItemCompetenceCreature.toArme(rollData.competence) + rollData.arme = RdDItemCompetenceCreature.toArme(rollData.competence); } } diff --git a/module/rdd-combat.js b/module/rdd-combat.js index 2daadbbb..c3c16c16 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -355,7 +355,7 @@ export class RdDCombat { } /* -------------------------------------------- */ - async attaque(competence, arme) { + async attaque(competence, arme = undefined) { if (!await this.accorderEntite('avant-attaque')) { return; } @@ -535,8 +535,8 @@ export class RdDCombat { /* -------------------------------------------- */ async parade(attackerRoll, armeParadeId) { - let arme = RdDItemArme.getArmeData(armeParadeId ? this.defender.getOwnedItem(armeParadeId) : null); - + let arme = this.defender.getArmeParade(armeParadeId); + console.log("RdDCombat.parade >>>", attackerRoll, armeParadeId, arme); let rollData = this._prepareParade(attackerRoll, arme); @@ -559,10 +559,11 @@ export class RdDCombat { dialog.render(true); } + _prepareParade(attackerRoll, armeParade) { const compName = armeParade.data.competence; const armeAttaque = attackerRoll.arme; - + let rollData = { passeArme: attackerRoll.passeArme, forceValue: this.defender.getForceValue(), @@ -581,15 +582,16 @@ export class RdDCombat { if (this.defender.isCreature()) { RdDItemCompetenceCreature.setRollDataCreature(rollData); } + return rollData; } /* -------------------------------------------- */ _getDiviseurSignificative(defenderRoll) { let facteurSign = 1; - if (defenderRoll.surprise == 'demi'){ + if (defenderRoll.surprise == 'demi') { facteurSign *= 2; - } + } if (defenderRoll.needParadeSignificative) { facteurSign *= 2; }