diff --git a/module/actor.js b/module/actor.js index ec2ac7cf..f107bc3e 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1850,26 +1850,6 @@ export class RdDActor extends RdDBaseActorSang { return undefined; } - async rollCaracCompetence(caracName, compName, diff, options = { title: "" }) { - RdDEmpoignade.checkEmpoignadeEnCours(this) - const competence = this.getCompetence(compName); - await this.openRollDialog({ - name: 'jet-competence', - label: 'Jet ' + Grammar.apostrophe('de', competence.name), - template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html', - rollData: { - alias: this.getAlias(), - carac: this.system.carac, - selectedCarac: this.getCaracByName(caracName), - selectedCaracName: caracName, - diffLibre: diff, - competence: competence, - show: { title: options?.title ?? '' } - }, - callbackAction: r => this.$onRollCompetence(r, options) - }); - } - /* -------------------------------------------- */ async rollTache(id, options = {}) { RdDEmpoignade.checkEmpoignadeEnCours(this) diff --git a/module/actor/base-actor-reve.js b/module/actor/base-actor-reve.js index ae40b532..b920cf8a 100644 --- a/module/actor/base-actor-reve.js +++ b/module/actor/base-actor-reve.js @@ -294,6 +294,25 @@ export class RdDBaseActorReve extends RdDBaseActor { createCallbackAppelAuMoral() { return this.createEmptyCallback(); } async _onCloseRollDialog(html) { } + async rollCaracCompetence(caracName, compName, diff, options = { title: "" }) { + RdDEmpoignade.checkEmpoignadeEnCours(this) + const competence = this.getCompetence(compName); + await this.openRollDialog({ + name: 'jet-competence', + label: competence? 'Jet ' + Grammar.apostrophe('de', competence.name) : `Jet sans compétence (${compName})`, + template: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-competence.html', + rollData: { + alias: this.getAlias(), + carac: this.system.carac, + selectedCarac: this.getCaracByName(caracName), + selectedCaracName: caracName, + diffLibre: diff, + competence: competence, + show: { title: options?.title ?? '' } + }, + callbackAction: r => this.$onRollCompetence(r, options) + }); + } /** * Méthode pour faire un jet prédéterminer sans ouvrir la fenêtre de dialogue * @param {*} caracName code ou label de la caractéristique. On peut utiliser 'intel' pour Intellect. diff --git a/module/actor/creature.js b/module/actor/creature.js index 78d3f0cc..8f65041f 100644 --- a/module/actor/creature.js +++ b/module/actor/creature.js @@ -36,12 +36,14 @@ export class RdDCreature extends RdDBaseActorSang { mapCarac(caracCode) { switch (caracCode) { - case 'vue': case 'ouie': - case 'odoratgout': - case 'empathie': + case 'vue': case 'ouie': case 'odoratgout': case 'empathie': case 'perception': return 'perception' + case 'agilite': + return 'force' + case 'force': case 'constitution': case 'taille': case 'reve': case 'volonte': + return caracCode } - return caracCode + return undefined } } diff --git a/module/actor/entite.js b/module/actor/entite.js index ee6e480b..eea0b9cb 100644 --- a/module/actor/entite.js +++ b/module/actor/entite.js @@ -121,6 +121,7 @@ export class RdDEntite extends RdDBaseActorReve { mapCarac(caracCode) { switch (caracCode) { case 'taille': + case 'reve': return caracCode } return 'reve' diff --git a/module/apps/textroll/text-roll-carac-competence.js b/module/apps/textroll/text-roll-carac-competence.js index 6441a2a8..71349c63 100644 --- a/module/apps/textroll/text-roll-carac-competence.js +++ b/module/apps/textroll/text-roll-carac-competence.js @@ -41,7 +41,7 @@ export class TextRollCaracCompetence { if (diff.match(REGEX_DICE_DIFF)) { const roll = new Roll(diff) await roll.evaluate() - await roll.toMessage({flavor: `La difficulté de ${diff} a donné ${roll.total}`}) + await roll.toMessage({ flavor: `La difficulté de ${diff} a donné ${roll.total}` }) return roll.total } return diff @@ -49,17 +49,14 @@ export class TextRollCaracCompetence { async doRoll(actor, caracCode, competence, diff) { caracCode = actor.mapCarac(caracCode) - if (competence) { - if (actor.type == ACTOR_TYPES.personnage) { + if (caracCode) { + if (competence) { await actor.rollCaracCompetence(caracCode, competence, diff) } else { - await actor.doRollCaracCompetence(caracCode, competence, diff) + await actor.rollCarac(caracCode, { diff }) } } - else { - await actor.rollCarac(caracCode, { diff }) - } } getSelectedActors(actor) { diff --git a/module/rdd-roll.js b/module/rdd-roll.js index b76e64b0..c6d2f029 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -8,6 +8,7 @@ import { RdDCarac } from "./rdd-carac.js"; import { RdDResolutionTable } from "./rdd-resolution-table.js"; import { ReglesOptionnelles } from "./settings/regles-optionnelles.js"; import { Grammar } from "./grammar.js"; +import { ACTOR_TYPES } from "./item.js"; /** * Extend the base Dialog entity to select roll parameters @@ -62,7 +63,7 @@ export class RdDRoll extends Dialog { forceDiceResult: -1 } // Mini patch :Ajout du rêve actuel - if (actor.system.type == "personnage") { + if (actor.type == ACTOR_TYPES.personnage) { defaultRollData.carac["reve-actuel"] = actor.system.reve.reve } @@ -131,11 +132,12 @@ export class RdDRoll extends Dialog { console.log('RdDRoll.activateListeners', this.rollData); // Update html, according to rollData - if (this.rollData.competence) { - const defaut_carac = this.rollData.competence.system.defaut_carac + if (!this.rollData.selectedCarac && this.rollData.competence) { // Set the default carac from the competence item - this.rollData.selectedCarac = this.rollData.carac[defaut_carac]; - this.html.find("[name='carac']").val(defaut_carac); + this.rollData.selectedCarac = this.rollData.carac[this.actor.mapCarac(this.rollData.competence.system.defaut_carac)] + } + if (this.rollData.selectedCarac) { + this.html.find("[name='carac']").val(RdDCarac.caracDetails(this.rollData.selectedCarac.label).code) } if (this.rollData.selectedSort) { this.setSelectedSort(this.rollData.selectedSort);