From 1b75decb18c2dc4c0d6b7516ff21e7979eaac442 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 11 Jan 2025 19:29:29 +0100 Subject: [PATCH] =?UTF-8?q?Utiliser=20les=20fen=C3=AAtres=20de=20jets=20po?= =?UTF-8?q?ur=20les=20jets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor-sheet.js | 2 +- module/actor/base-actor-reve-sheet.js | 2 +- module/actor/base-actor-reve.js | 8 +++++--- module/apps/rdd-text-roll.js | 18 ++++++++++++++++-- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 257835ab..7831bce3 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -222,7 +222,7 @@ export class RdDActorSheet extends RdDBaseActorSangSheet { } // Points de reve actuel - this.html.find('.roll-reve-actuel').click(async event => this.actor.rollCarac('reve-actuel', true)) + this.html.find('.roll-reve-actuel').click(async event => this.actor.rollCarac('reve-actuel', {resistance:true})) this.html.find('.empoignade-label a').click(async event => RdDEmpoignade.onAttaqueEmpoignadeFromItem(RdDSheetUtility.getItem(event, this.actor))) this.html.find('.roll-arme').click(async event => this.actor.rollArme(foundry.utils.duplicate(this._getEventArmeCombat(event)), 'competence')) diff --git a/module/actor/base-actor-reve-sheet.js b/module/actor/base-actor-reve-sheet.js index 6c0fc1ff..2e5fa022 100644 --- a/module/actor/base-actor-reve-sheet.js +++ b/module/actor/base-actor-reve-sheet.js @@ -28,7 +28,7 @@ export class RdDBaseActorReveSheet extends RdDBaseActorSheet { this.html.find('.button-encaissement').click(async event => this.actor.encaisser()) this.html.find('.roll-carac').click(async event => { - this.actor.rollCarac(Grammar.toLowerCaseNoAccent(event.currentTarget.attributes['data-carac-name'].value))}); + this.actor.rollCarac(Grammar.toLowerCaseNoAccent(event.currentTarget.attributes['data-carac-name'].value))}) this.html.find('.roll-competence').click(async event => this.actor.rollCompetence(RdDSheetUtility.getItemId(event))); this.html.find('.endurance-plus').click(async event => this.actor.santeIncDec("endurance", 1)); this.html.find('.endurance-moins').click(async event => this.actor.santeIncDec("endurance", -1)); diff --git a/module/actor/base-actor-reve.js b/module/actor/base-actor-reve.js index bb71912f..1d21d9b7 100644 --- a/module/actor/base-actor-reve.js +++ b/module/actor/base-actor-reve.js @@ -344,14 +344,15 @@ export class RdDBaseActorReve extends RdDBaseActor { competences: this.itemTypes['competence'] }, callbackAction: r => this.$onRollCaracResult(r) - }); + }) } /* -------------------------------------------- */ - async rollCarac(caracName, jetResistance = undefined) { + async rollCarac(caracName, options = {}) { if (Grammar.equalsInsensitive(caracName, 'taille')) { return } + foundry.utils.mergeObject(options, { resistance: false, diff: 0 }, { overwrite: false }) RdDEmpoignade.checkEmpoignadeEnCours(this) let selectedCarac = this.getCaracByName(caracName) console.log("selectedCarac", selectedCarac) @@ -362,7 +363,8 @@ export class RdDBaseActorReve extends RdDBaseActor { rollData: { selectedCarac: selectedCarac, competences: this.itemTypes['competence'], - jetResistance: jetResistance ? caracName : undefined + diffLibre: options.diff ?? 0, + jetResistance: options.resistance ? caracName : undefined }, callbackAction: r => this.$onRollCaracResult(r) }); diff --git a/module/apps/rdd-text-roll.js b/module/apps/rdd-text-roll.js index bca89208..7a808d61 100644 --- a/module/apps/rdd-text-roll.js +++ b/module/apps/rdd-text-roll.js @@ -32,12 +32,26 @@ class TextRollCaracCompetence { const path = RdDCarac.caracDetails(caracCode)?.path const actors = TextRollCaracCompetence.getSelectedActors(actor) actors.filter(it => foundry.utils.getProperty(it, path) != undefined) - .forEach(it => it.doRollCaracCompetence(caracCode, competence, diff)) + .forEach(it => TextRollCaracCompetence.doRoll(it, caracCode, competence, diff)) } } + static async doRoll(actor, caracCode, competence, diff) { + if (competence) { + if (actor.type == ACTOR_TYPES.personnage) { + actor.rollCaracCompetence(caracCode, competence, diff) + } + else { + actor.doRollCaracCompetence(caracCode, competence, diff) + } + } + else { + actor.rollCarac(caracCode, { diff }) + } + } + static getSelectedActors(actor) { const selected = canvas.tokens.controlled.map(it => it.actor).filter(it => it) - if (selected.length > 0){ + if (selected.length > 0) { return selected } actor = actor ?? RdDUtility.getSelectedActor()