From 78b4eef45317a49808920f74561cb9b4d90cd1a8 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Mon, 16 Nov 2020 21:18:18 +0100 Subject: [PATCH] Fix initiative pour les creatures/entites --- module/rdd-main.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/module/rdd-main.js b/module/rdd-main.js index 9b438cb5..6e9e6cf5 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -44,18 +44,26 @@ const _patch_initiative = () => { const c = this.getCombatant( ids[cId] ); //if (!c) return results; - let armeCombat; - for (const item of c.actor.data.items) { - if (item.type == "arme" && item.data.equipe) { - armeCombat = duplicate(item); + let armeCombat, rollFormula, competence; + if ( c.actor.data.type == 'creature' || c.actor.data.type == 'entite') { + for (const competenceItem of c.actor.data.items) { + if ( competenceItem.data.iscombat) { + competence = duplicate(competenceItem); + } } + rollFormula = "1d6+" + competence.data.niveau + "+" + Math.ceil(competence.data.carac_value / 2); + } else { + for (const item of c.actor.data.items) { + if (item.type == "arme" && item.data.equipe) { + armeCombat = duplicate(item); + } + } + let compName = ( armeCombat == undefined ) ? "Corps à corps" : armeCombat.data.competence; + competence = RdDUtility.findCompetence( c.actor.data.items, compName ); + rollFormula = "1d6+" + competence.data.niveau + "+" + Math.ceil(c.actor.data.data.carac[competence.data.defaut_carac].value/2); } //console.log("Combatat", c); - let compName = ( armeCombat == undefined ) ? "Corps à corps" : armeCombat.data.competence; - let competence = RdDUtility.findCompetence( c.actor.data.items, compName ); - //const cf = formula || this._getInitiativeFormula(c); - let rollFormula = "1d6+" + competence.data.niveau + "+" + Math.ceil(c.actor.data.data.carac[competence.data.defaut_carac].value/2); const roll = this._getInitiativeRoll(c, rollFormula); //console.log("Compute init for", armeCombat, competence, rollFormula, roll.total);