From 6fc6bfc54063557411340975359ae2c0a70b58f1 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 20 Nov 2021 02:53:28 +0100 Subject: [PATCH] =?UTF-8?q?Plusieurs=20comp=C3=A9tences=20esquive?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pour les sirènes! --- module/rdd-combat.js | 38 ++++++++++++++--------------- templates/actor-sheet.html | 23 +++++++++++------ templates/chat-demande-defense.html | 13 +++++++--- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/module/rdd-combat.js b/module/rdd-combat.js index e8de4d6e..4fb9e504 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -626,11 +626,13 @@ export class RdDCombat { const defenderTokenId = event.currentTarget.attributes['data-defenderTokenId']?.value; const armeParadeId = event.currentTarget.attributes['data-armeid']?.value; + const competence = event.currentTarget.attributes['data-competence']?.value; + const compId = event.currentTarget.attributes['data-compid']?.value; switch (button) { case '#particuliere-attaque': return await this.choixParticuliere(attackerRoll, event.currentTarget.attributes['data-mode'].value); - case '#parer-button': return this.parade(attackerRoll, armeParadeId); - case '#esquiver-button': return this.esquive(attackerRoll); + case '#parer-button': return this.parade(attackerRoll, armeParadeId, competence); + case '#esquiver-button': return this.esquive(attackerRoll, compId, competence); case '#encaisser-button': return this.encaisser(attackerRoll, defenderTokenId); case '#echec-total-attaque': return this._onEchecTotal(attackerRoll); @@ -872,7 +874,7 @@ export class RdDCombat { await this._sendMessageDefense(attackerRoll, defenderRoll); } } - + /* -------------------------------------------- */ isPossession( attackerRoll) { return attackerRoll.selectedCarac.label.toLowerCase() == 'possession'; @@ -888,18 +890,18 @@ export class RdDCombat { } // # utilisation esquive - const esquive = Misc.data(this.defender.getCompetence("esquive")); - const corpsACorps = Misc.data(this.defender.getCompetence("Corps à corps")); - const esquiveUsage = esquive ? this.defender.getItemUse(esquive._id) : 0; + const corpsACorps = Misc.data(this.defender.getCompetence("Corps à corps", { onMessage: it => console.info(it, this.defender) })); + const esquives = duplicate(this.defender.getCompetences("esquive", { onMessage: it => console.info(it, this.defender) }).map(c => Misc.data(c))); + esquives.forEach(e => e.usages = e?.id ? this.defender.getItemUse(e.id) : 0); const paramChatDefense = { passeArme: attackerRoll.passeArme, essais: attackerRoll.essais, - isPossession: this.isPossession( attackerRoll), + isPossession: this.isPossession(attackerRoll), defender: Misc.data(this.defender), attacker: Misc.data(this.attacker), attackerId: this.attackerId, - esquiveUsage: esquiveUsage, + esquives: esquives, defenderTokenId: this.defenderTokenId, mainsNues: attackerRoll.dmg.mortalite != 'mortel' && corpsACorps, armes: this._filterArmesParade(this.defender, attackerRoll.competence, attackerRoll.arme), @@ -1014,12 +1016,12 @@ export class RdDCombat { } /* -------------------------------------------- */ - async parade(attackerRoll, armeParadeId) { + async parade(attackerRoll, armeParadeId, competence) { let arme = this.defender.getArmeParade(armeParadeId); console.log("RdDCombat.parade >>>", attackerRoll, armeParadeId, arme); - let rollData = this._prepareParade(attackerRoll, arme); + let rollData = this._prepareParade(attackerRoll, arme, competence); const dialog = await RdDRoll.create(this.defender, rollData, { @@ -1042,20 +1044,16 @@ export class RdDCombat { } /* -------------------------------------------- */ - _prepareParade(attackerRoll, armeParade) { - const compName = armeParade.data.competence; - const armeAttaque = attackerRoll.arme; - const parade = Misc.data(this.defender.getCompetence(compName)); - + _prepareParade(attackerRoll, armeParade, competenceParade) { let defenderRoll = { passeArme: attackerRoll.passeArme, diffLibre: attackerRoll.diffLibre, attackerRoll: attackerRoll, - competence: parade, + competence: Misc.data(this.defender.getCompetence(competenceParade)), arme: armeParade, surprise: this.defender.getSurprise(true), needParadeSignificative: ReglesOptionelles.isUsing('categorieParade') && RdDItemArme.needParadeSignificative(armeAttaque, armeParade), - needResist: RdDItemArme.needArmeResist(armeAttaque, armeParade), + needResist: RdDItemArme.needArmeResist(attackerRoll.arme, armeParade), carac: Misc.templateData(this.defender).carac, show: {} }; @@ -1101,10 +1099,10 @@ export class RdDCombat { } /* -------------------------------------------- */ - async esquive(attackerRoll) { - const esquive = Misc.data(this.defender.getCompetence("esquive")); + async esquive(attackerRoll, compId, compName) { + const esquive = Misc.data(this.defender.getCompetence(compId) ?? this.defender.getCompetence(compName)); if (esquive == undefined) { - ui.notifications.error(this.defender.name + " n'a pas de compétence 'esquive'"); + ui.notifications.error(this.defender.name + " n'a pas de compétence " + compName); return; } console.log("RdDCombat.esquive >>>", attackerRoll, esquive); diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index a739487c..fc36ed3b 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -290,13 +290,22 @@ {{numberFormat arme.data.dommagesReels decimals=0 sign=true}} {{/each}} -
  • - {{esquive.name}} - - - {{numberFormat esquive.niveau decimals=0 sign=true}} - -
  • + {{#each esquives as |esq key|}} +
  • + + + + {{esq.name}} + {{log esq}} + + + + + {{numberFormat esq.data.niveau decimals=0 sign=true}} + +
  • + {{/each}} +
    {{!-- Liste de blessures --}} diff --git a/templates/chat-demande-defense.html b/templates/chat-demande-defense.html index c733f73d..9864da84 100644 --- a/templates/chat-demande-defense.html +++ b/templates/chat-demande-defense.html @@ -36,22 +36,27 @@ {{/unless}} {{else}} {{#each armes as |arme key|}} - + Parer avec {{arme.name}} à {{../diffLibre }}{{#if arme.data.nbUsage}} (Utilisations : {{arme.data.nbUsage}}){{/if}}
    {{/each}} {{#if mainsNues}} - + Parer à mains nues à {{diffLibre}}{{#if arme.data.nbUsage}} (Utilisations : {{arme.data.nbUsage}}){{/if}}
    {{/if}} {{#if (ne attaqueCategorie 'tir')}} - - Esquiver à {{diffLibre}} {{#if esquiveUsage}} (Utilisations : {{esquiveUsage}}){{/if}} + {{#each esquives as |esq key|}} + + {{esq.name}} à {{../diffLibre}} {{#if esq.usage}} (Utilisations : {{esq.usage}}){{/if}}
    + {{/each}} {{/if}} {{/if}} {{/unless}}