diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 53e04120..7b2a7557 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -37,7 +37,7 @@ export class RdDActorSheet extends ActorSheet { /* -------------------------------------------- */ async getData() { const objectData = Misc.data(this.object); - + //this.actor.checkMonnaiePresence(this.actor.data.items); // Always check let formData = { diff --git a/module/actor.js b/module/actor.js index ae849614..1f406a61 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1670,7 +1670,7 @@ export class RdDActor extends Actor { } async _jetEndurance(endurance) { - const roll = await RdDDice.roll("1d20", { showDice: true }); + const roll = await RdDDice.roll("1d20"); let result = { roll: roll, sonne: roll.total > endurance || roll.total == 20 // 20 is always a failure @@ -1683,7 +1683,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async jetVie() { - let roll = await RdDDice.roll("1d20", { showDice: true }); + let roll = await RdDDice.roll("1d20"); const actorData = Misc.data(this); let msgText = "Jet de Vie : " + roll.total + " / " + actorData.data.sante.vie.value + "
"; if (roll.total <= actorData.data.sante.vie.value) { @@ -1819,7 +1819,7 @@ export class RdDActor extends Actor { async _jetDeMoral(situation) { const moralActuel = Misc.toInt(Misc.templateData(this).compteurs.moral.value); - const jet = await RdDDice.rollTotal("1d20", { showDice: true }); + const jet = await RdDDice.rollTotal("1d20"); const difficulte = 10 + moralActuel; const succes = jet <= difficulte; const jetMoral = { @@ -2020,8 +2020,7 @@ export class RdDActor extends Actor { selectedCarac: actorData.data.sante.vie, carac: actorData.data.carac, caracValue: actorData.data.sante.vie.max, - finalLevel: etat + forceAlcool - nbDoses, - showDice: true + finalLevel: etat + forceAlcool - nbDoses }, } @@ -2034,7 +2033,7 @@ export class RdDActor extends Actor { ethylisme.value = Math.max(ethylisme.value - 1, -7); ethylisme.nb_doses = 0; - let perte = await RdDDice.rollTotal("1d6", { showDice: true }); + let perte = await RdDDice.rollTotal("1d6"); ethylismeData.perteEndurance = await this.santeIncDec("endurance", -perte); if (!ethylisme.jet_moral) { @@ -2055,8 +2054,7 @@ export class RdDActor extends Actor { selectedCarac: actorData.data.carac.volonte, caracValue: actorData.data.carac.volonte.value, ethylisme: ethylisme.value, - finalLevel: ethylisme.value + actorData.data.compteurs.moral.value, - showDice: true + finalLevel: ethylisme.value + actorData.data.compteurs.moral.value } await RdDResolutionTable.rollData(ethylismeData.jetVolonte); this._appliquerExperienceRollData(ethylismeData.jetVolonte); @@ -2500,7 +2498,6 @@ export class RdDActor extends Actor { selectedCarac: carac, competence: competence, diffLibre: diff, - showDice: true, show: { title: options?.title ?? '' } }; RollDataAjustements.calcul(rollData, this); @@ -3363,7 +3360,7 @@ export class RdDActor extends Actor { } } - let roll = await RdDDice.roll(formula, { showDice: true }); + let roll = await RdDDice.roll(formula); // 1 dé fait au minmum la difficulté libre if (ReglesOptionelles.isUsing('degat-minimum-malus-libre-simple')) { diff --git a/module/constants.js b/module/constants.js index 708e4ab5..be1d1c86 100644 --- a/module/constants.js +++ b/module/constants.js @@ -1 +1,4 @@ export const SYSTEM_RDD = "foundryvtt-reve-de-dragon"; + +export const HIDE_DICE = 'hide'; +export const SHOW_DICE = 'show'; diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index aa923569..27763510 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -7,7 +7,7 @@ import { RdDUtility } from "./rdd-utility.js"; import { Grammar } from "./grammar.js"; import { RdDDice } from "./rdd-dice.js"; import { Misc } from "./misc.js"; -import { SYSTEM_RDD } from "./constants.js"; +import { HIDE_DICE, SHOW_DICE, SHOW_DICE_OPTIONAL, SYSTEM_RDD } from "./constants.js"; /* -------------------------------------------- */ const dossierIconesHeures = 'systems/foundryvtt-reve-de-dragon/icons/heures/' @@ -145,10 +145,10 @@ export class RdDCalendrier extends Application { } /* -------------------------------------------- */ - async ajouterNombreAstral(index, showDice = true) { - const nombreAstral = await RdDDice.rollTotal("1dh", { showDice: showDice, hideDice: !showDice, rollMode: "selfroll" }); + async ajouterNombreAstral(index, showDice = SHOW_DICE_OPTIONAL) { + const nombreAstral = await RdDDice.rollTotal("1dh", { showDice: showDice, rollMode: "selfroll" }); const dateFuture = this.getDateFromIndex(index); - if (showDice) { + if (showDice != HIDE_DICE) { ChatMessage.create({ whisper: ChatMessage.getWhisperRecipients("GM"), content: `Le chiffre astrologique du ${dateFuture} sera le ${nombreAstral}` @@ -185,7 +185,7 @@ export class RdDCalendrier extends Application { } /* -------------------------------------------- */ - async rebuildListeNombreAstral(showDice = true) { + async rebuildListeNombreAstral(showDice = SHOW_DICE) { if (Misc.isUniqueConnectedGM()) { console.log("rebuildListeNombreAstral", showDice); let jourCourant = this.getCurrentDayIndex(); @@ -324,7 +324,7 @@ export class RdDCalendrier extends Application { let rollData = { caracValue: request.carac_vue, finalLevel: niveau, - showDice: false, + showDice: HIDE_DICE, rollMode: "blindroll" }; await RdDResolutionTable.rollData(rollData); @@ -333,7 +333,7 @@ export class RdDCalendrier extends Application { request.isValid = true; if (!request.rolled.isSuccess) { request.isValid = false; - nbAstral = await RdDDice.rollTotal("1dhr" + nbAstral, { showDice: true, rollMode: "selfroll" }); + nbAstral = await RdDDice.rollTotal("1dhr" + nbAstral, { rollMode: "selfroll" }); // Mise à jour des nombres astraux du joueur let astralData = this.listeNombreAstral.find((nombreAstral, i) => nombreAstral.index == request.date); astralData.valeursFausses.push({ actorId: request.id, nombreAstral: nbAstral }); diff --git a/module/rdd-combat.js b/module/rdd-combat.js index 107b9a52..8d363432 100644 --- a/module/rdd-combat.js +++ b/module/rdd-combat.js @@ -1,5 +1,5 @@ import { ChatUtility } from "./chat-utility.js"; -import { SYSTEM_RDD } from "./constants.js"; +import { HIDE_DICE, SYSTEM_RDD } from "./constants.js"; import { RdDItemArme } from "./item-arme.js"; import { RdDItemCompetence } from "./item-competence.js"; import { RdDItemCompetenceCreature } from "./item-competencecreature.js"; @@ -1195,7 +1195,7 @@ export class RdDCombat { let resistRoll = await RdDResolutionTable.rollData({ caracValue: resistance, finalLevel: - dmg, - showDice: false + showDice: HIDE_DICE }); if (!resistRoll.rolled.isSuccess) { let perteResistance = (dmg - arme.data.resistance_magique) @@ -1210,7 +1210,7 @@ export class RdDCombat { let resistRoll = await RdDResolutionTable.rollData({ caracValue: resistance, finalLevel: - dmg, - showDice: false + showDice: HIDE_DICE }); if (resistRoll.rolled.isSuccess) { // Perte de résistance defenderRoll.show.deteriorationArme = 'resiste'; @@ -1226,7 +1226,7 @@ export class RdDCombat { let desarme = await RdDResolutionTable.rollData({ caracValue: this.defender.getForce(), finalLevel: Misc.toInt(defenderRoll.competence.data.niveau) - dmg, - showDice: false + showDice: HIDE_DICE }); defenderRoll.show.desarme = desarme.rolled.isEchec; } diff --git a/module/rdd-commands.js b/module/rdd-commands.js index 5e1a1c6d..94543a56 100644 --- a/module/rdd-commands.js +++ b/module/rdd-commands.js @@ -291,7 +291,6 @@ export class RdDCommands { let rollData = { caracValue: carac, finalLevel: diff, - showDice: true, diviseurSignificative: significative ? 2 : 1, show: { title: "Table de résolution" } }; @@ -301,7 +300,7 @@ export class RdDCommands { /* -------------------------------------------- */ async rollDeDraconique(msg) { - let ddr = await RdDDice.rollTotal("1dr + 7", { showDice: true }); + let ddr = await RdDDice.rollTotal("1dr + 7"); RdDCommands._chatAnswer(msg, `Lancer d'un Dé draconique: ${ddr}`); } diff --git a/module/rdd-dice.js b/module/rdd-dice.js index 05792f30..e5a1faaf 100644 --- a/module/rdd-dice.js +++ b/module/rdd-dice.js @@ -1,5 +1,5 @@ import { ChatUtility } from "./chat-utility.js"; -import { SYSTEM_RDD } from "./constants.js"; +import { HIDE_DICE, SHOW_DICE, SHOW_DICE_OPTIONAL, SYSTEM_RDD } from "./constants.js"; import { Misc } from "./misc.js"; function img(src) { @@ -123,6 +123,7 @@ export class RdDDice { CONFIG.Dice.terms[DeDraconique.DENOMINATION] = DeDraconique; CONFIG.Dice.terms[DeHeure.DENOMINATION] = DeHeure; } + static onReady() { if (game.modules.get("dice-so-nice")?.active) { if (game.settings.get("core", "noCanvas")) { @@ -131,17 +132,16 @@ export class RdDDice { } } - static async roll(formula, options = { showDice: false, rollMode: undefined }) { + static async roll(formula, options = { showDice: SHOW_DICE, rollMode: undefined }) { const roll = new Roll(formula); await roll.evaluate({ async: true }); - if (!options.hideDice) { - roll.showDice = options.showDice; - await RdDDice.show(roll, options.rollMode ?? game.settings.get("core", "rollMode")); + if (options.showDice != HIDE_DICE) { + await this.showDiceSoNice(roll, options.rollMode ?? game.settings.get("core", "rollMode")); } return roll; } - static async rollTotal(formula, options = { showDice: false, hideDice: false }) { + static async rollTotal(formula, options = { showDice: HIDE_DICE}) { const roll = await RdDDice.roll(formula, options); return roll.total; } @@ -159,14 +159,6 @@ export class RdDDice { } } - /* -------------------------------------------- */ - static async show(roll, rollMode) { - if (roll.showDice || game.settings.get(SYSTEM_RDD, "dice-so-nice") == true) { - await this.showDiceSoNice(roll, rollMode); - } - return roll; - } - /* -------------------------------------------- */ static async showDiceSoNice(roll, rollMode) { if (game.modules.get("dice-so-nice")?.active) { diff --git a/module/rdd-main.js b/module/rdd-main.js index 503854fe..8235d737 100644 --- a/module/rdd-main.js +++ b/module/rdd-main.js @@ -106,17 +106,6 @@ Hooks.once("init", async function () { default: RdDCalendrier.createCalendrierPos(), type: Object }); - - /* -------------------------------------------- */ - game.settings.register(SYSTEM_RDD, "dice-so-nice", { - name: "Montrer les dés pour toutes les jets", - hint: "Utilise Dice So Nice pour tous les jets de dés possibles. Décocher pour limiter à la table de résolution", - scope: "client", - config: true, - default: false, - type: Boolean - }); - /* -------------------------------------------- */ game.settings.register(SYSTEM_RDD, "supprimer-dialogues-combat-chat", { name: "Supprimer les dialogues de combat",