From b4f298256a440a69f88fbad9c408f5e0440262c4 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Thu, 17 Dec 2020 00:23:40 +0100 Subject: [PATCH] =?UTF-8?q?parade=20corps=20=C3=A0=20corps=20#68?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/item-arme.js | 7 ++++--- module/rdd-combat.js | 31 +++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/module/item-arme.js b/module/item-arme.js index feedde73..ce733b5b 100644 --- a/module/item-arme.js +++ b/module/item-arme.js @@ -69,9 +69,10 @@ export class RdDItemArme extends Item { } static mainsNues() { - return { + const mainsNues = { name: "Mains nues", - data: { unemain: true, deuxmains: false, dommages: 0, dommagesReels: 0, mortalite: 'non-mortel' } - } + data: { unemain: true, deuxmains: false, dommages: 0, dommagesReels: 0, mortalite: 'non-mortel', competence: 'Corps à corps' } + }; + return mainsNues } } diff --git a/module/rdd-combat.js b/module/rdd-combat.js index be291876..c63bc7e0 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -81,7 +81,10 @@ export class RdDCombat { } switch (button) { case '#particuliere-attaque': return await this.choixParticuliere(rollData, event.currentTarget.attributes['data-mode'].value); - case '#parer-button': return this.parade(rollData, event.currentTarget.attributes['data-armeid'].value); + case '#parer-button': { + const armeId = event.currentTarget.attributes['data-armeid']; + return this.parade(rollData, armeId ? armeId.value : undefined); + } case '#esquiver-button': return this.esquive(rollData); case '#encaisser-button': return this.encaisser(rollData, event.currentTarget.attributes['data-defenderTokenId'].value); } @@ -255,7 +258,10 @@ export class RdDCombat { for (const arme of this._filterArmesParade(this.defender.data.items, rollData.competence.data.categorie)) { content += "
Parer avec " + arme.name + ""; } - + // corps à corps + if (rollData.dmg.mortalite != 'mortel') { + content += "
Parer à mains nues"; + } // esquive if (rollData.competence.data.categorie == 'melee' || rollData.competence.data.categorie == "lancer" || rollData.competence.data.categorie == 'competencecreature') { content += "
Esquiver"; @@ -339,7 +345,8 @@ export class RdDCombat { /* -------------------------------------------- */ async parade(attackerRoll, armeParadeId) { - let arme = this.defender.getOwnedItem(armeParadeId); + + let arme = this._findArmeParade(armeParadeId); console.log("RdDCombat.parade >>>", attackerRoll, armeParadeId, arme); @@ -361,13 +368,21 @@ export class RdDCombat { dialog.render(true); } - _prepareParade(attackerRoll, arme) { + _findArmeParade(armeParadeId) { + if (armeParadeId) { + const armeItem = this.defender.getOwnedItem(armeParadeId); + return armeItem.data; + + } + return RdDItemArme.mainsNues() + } + + _prepareParade(attackerRoll, armeParade) { const isCreature = this.defender.isCreature(); - const compName = isCreature ? arme.name : arme.data.data.competence; + const compName = isCreature ? armeParade.name : armeParade.data.competence; const competence = this.defender.getCompetence(compName); const armeAttaque = attackerRoll.arme; - const armeParade = arme.data; - + if (compName != competence.name) { // TODO: toujours utiliser competence.name ... ui.notifications.warn("Différence entre compétence " + competence.name + " et compétence de l'arme " + compName); @@ -378,7 +393,7 @@ export class RdDCombat { diffLibre: attackerRoll.diffLibre, attackerRoll: attackerRoll, competence: competence, - arme: arme.data, + arme: armeParade, surprise: this.defender.getSurprise(), surpriseDefenseur: this.defender.getSurprise(), needSignificative: this._needSignificative(attackerRoll) || RdDItemArme.needParadeSignificative(armeAttaque, armeParade),