diff --git a/module/actor.js b/module/actor.js index 8e813305..1b5dded2 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1292,7 +1292,7 @@ export class RdDActor extends Actor { } isSurenc() { - return this.isPersonnage() ? (this.system.compteurs.surenc.value < 0) : false + return this.isPersonnage() ? (this.computeMalusSurEncombrement() < 0) : false } /* -------------------------------------------- */ @@ -1303,6 +1303,7 @@ export class RdDActor extends Actor { } return Math.min(0, this.getEncombrementMax() - Math.ceil(Number(this.getEncTotal()))); } + getMessageSurEncombrement() { return this.computeMalusSurEncombrement() < 0 ? "Sur-Encombrement!" : ""; } @@ -1337,17 +1338,15 @@ export class RdDActor extends Actor { async computeEncombrementTotalEtMalusArmure() { if (!this.pack) { await this.computeMalusArmure(); - return this.computeEncombrement(); + this.encTotal = this.items.map(it => it.getEncTotal()).reduce(Misc.sum(), 0); + if (!this.isVehicule()) { + this.system.compteurs.surenc.value = this.computeMalusSurEncombrement(); + } + return this.encTotal; } return 0; } - /* -------------------------------------------- */ - computeEncombrement() { - this.encTotal = this.items.map(it => it.getEncTotal()).reduce(Misc.sum(), 0); - return this.encTotal; - } - /* -------------------------------------------- */ async computeMalusArmure() { if (this.isPersonnage()) { @@ -1419,9 +1418,6 @@ export class RdDActor extends Actor { state += Math.min(0, (compteurs.ethylisme?.value ?? 0)); compteurs.etat.value = state; - if (compteurs?.surenc) { - compteurs.surenc.value = this.computeMalusSurEncombrement(); - } } /* -------------------------------------------- */ @@ -2273,7 +2269,7 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async _appliquerAppelMoral(rollData) { if (!this.isPersonnage()) return; - if (!rollData.useMoral) return; + if (!rollData.use.moral) return; if (rollData.rolled.isEchec || (rollData.ajustements.diviseurSignificative && (rollData.rolled.roll * rollData.ajustements.diviseurSignificative > rollData.score))) { rollData.perteMoralEchec = rollData.moral <= -3 ? 'dissolution' : 'perte'; diff --git a/module/rdd-carac.js b/module/rdd-carac.js index 252094bc..e753a696 100644 --- a/module/rdd-carac.js +++ b/module/rdd-carac.js @@ -52,6 +52,11 @@ export class RdDCarac { return selectedCarac?.label?.toLowerCase()?.match(/r(e|ê)ve(( |-)actuel)?/); } + static isActionPhysique(selectedCarac) { + return !selectedCarac || + selectedCarac?.label.match(/(Apparence|Force|Agilité|Dextérité|Vue|Ouïe|Odorat-Goût|Empathie|Dérobée|Mêlée|Tir|Lancer)/); + } + static isIgnoreEtatGeneral(rollData) { const selectedCarac = rollData.selectedCarac; return !selectedCarac || diff --git a/module/rdd-roll.js b/module/rdd-roll.js index 836bce49..a8253ad6 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -38,28 +38,27 @@ export class RdDRoll extends Dialog { /* -------------------------------------------- */ static _setDefaultOptions(actor, rollData) { - const actorData = actor.system let defaultRollData = { alias: actor.name, ajustementsConditions: CONFIG.RDD.ajustementsConditions, difficultesLibres: CONFIG.RDD.difficultesLibres, etat: actor.getEtatGeneral(), moral: actor.getMoralTotal(), /* La valeur du moral pour les jets de volonté */ - carac: actorData.carac, + carac: actor.system.carac, finalLevel: 0, diffConditions: 0, diffLibre: rollData.competence?.system.default_diffLibre ?? 0, - malusArmureValue: actor.getMalusArmure(), - surencMalusValue: actor.computeMalusSurEncombrement(), - useMoral: false, /* Est-ce que le joueur demande d'utiliser le moral ? Utile si le joueur change plusieurs fois de carac associée. */ perteMoralEchec: false, /* Pour l'affichage dans le chat */ use: { + moral: false, /* Est-ce que le joueur demande d'utiliser le moral ? Utile si le joueur change plusieurs fois de carac associée. */ libre: true, conditions: true, - surenc: false, - encTotal: false + surenc: actor.isSurenc(), + encTotal: true }, - isMalusEncombrementTotal: rollData.competence ? RdDItemCompetence.isMalusEncombrementTotal(rollData.competence) : 0, + isMalusEncombrementTotal: RdDItemCompetence.isMalusEncombrementTotal(rollData.competence), + malusArmureValue: actor.getMalusArmure(), + surencMalusValue: actor.computeMalusSurEncombrement(), encTotal: actor.getEncTotal(), ajustementAstrologique: actor.ajustementAstrologique(), surprise: actor.getSurprise(false), @@ -68,8 +67,8 @@ export class RdDRoll extends Dialog { forceDiceResult: -1 } // Mini patch :Ajout du rêve actuel - if ( actorData.type == "personnage") { - defaultRollData.carac["reve-actuel"] = actorData.reve.reve + if ( actor.system.type == "personnage") { + defaultRollData.carac["reve-actuel"] = actor.system.reve.reve } mergeObject(rollData, defaultRollData, { recursive: true, overwrite: false }); @@ -260,10 +259,10 @@ export class RdDRoll extends Dialog { this.updateRollResult(); }); html.find('.appel-moral').click((event) => { /* l'appel au moral, qui donne un bonus de +1 */ - this.rollData.useMoral = !this.rollData.useMoral; + this.rollData.use.moral = !this.rollData.use.moral; const appelMoral = html.find('.icon-appel-moral')[0]; const tooltip = html.find('.tooltipAppelAuMoralText')[0]; - if (this.rollData.useMoral) { + if (this.rollData.use.moral) { if (this.rollData.moral > 0) { tooltip.innerHTML = "Appel au moral"; appelMoral.src = "/systems/foundryvtt-reve-de-dragon/icons/moral-heureux.svg"; @@ -334,8 +333,9 @@ export class RdDRoll extends Dialog { RollDataAjustements.calcul(rollData, this.actor); rollData.finalLevel = this._computeFinalLevel(rollData); - HtmlUtility._showControlWhen($(".use-encTotal"), rollData.ajustements.encTotal.visible); - HtmlUtility._showControlWhen($(".use-surenc"), rollData.ajustements.surenc.visible); + HtmlUtility._showControlWhen($(".use-encTotal"), rollData.ajustements.encTotal.visible && RdDCarac.isAgiliteOuDerivee(rollData.selectedCarac)); + HtmlUtility._showControlWhen($(".use-surenc"), rollData.ajustements.surenc.visible && RdDCarac.isActionPhysique(rollData.selectedCarac)); + HtmlUtility._showControlWhen($(".utilisation-moral"), rollData.use.appelAuMoral); HtmlUtility._showControlWhen($(".diffMoral"), rollData.ajustements.moralTotal.used); HtmlUtility._showControlWhen($(".divAppelAuMoral"), rollData.use.appelAuMoral); HtmlUtility._showControlWhen($("#etat-general"), !RdDCarac.isIgnoreEtatGeneral(rollData)); diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 636487a0..30cc52b0 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -14,6 +14,7 @@ import { RdDPossession } from "./rdd-possession.js"; import { RdDNameGen } from "./rdd-namegen.js"; import { RdDConfirm } from "./rdd-confirm.js"; import { RdDCalendrier } from "./rdd-calendrier.js"; +import { RdDCarac } from "./rdd-carac.js"; /* -------------------------------------------- */ // This table starts at 0 -> niveau -10 diff --git a/module/rolldata-ajustements.js b/module/rolldata-ajustements.js index 1824c60c..08b2654d 100644 --- a/module/rolldata-ajustements.js +++ b/module/rolldata-ajustements.js @@ -62,8 +62,8 @@ export const referenceAjustements = { getValue: (rollData, actor) => actor.getMalusArmure() }, encTotal: { - isVisible: (rollData, actor) => RdDItemCompetence.isMalusEncombrementTotal(rollData.competence), - isUsed: (rollData, actor) => rollData.use.encTotal, + isVisible: (rollData, actor) => RdDCarac.isAgiliteOuDerivee(rollData.selectedCarac) && RdDItemCompetence.isMalusEncombrementTotal(rollData.competence), + isUsed: (rollData, actor) => RdDCarac.isAgiliteOuDerivee(rollData.selectedCarac) && RdDItemCompetence.isMalusEncombrementTotal(rollData.competence) && rollData.use.encTotal, getLabel: (rollData, actor) => 'Encombrement total', getValue: (rollData, actor) => -actor.getEncTotal() }, @@ -74,8 +74,8 @@ export const referenceAjustements = { getValue: (rollData, actor) => actor.computeMalusSurEncombrement() }, moral: { - isVisible: (rollData, actor) => actor.isPersonnage() && RdDCarac.isActionPhysique(rollData.selectedCarac) && rollData.useMoral, - isUsed: (rollData, actor) => rollData.useMoral, + isVisible: (rollData, actor) => actor.isPersonnage() && RdDCarac.isActionPhysique(rollData.selectedCarac) && rollData.use.moral, + isUsed: (rollData, actor) => rollData.use.moral, getLabel: (rollData, actor) => 'Appel au moral', getValue: (rollData, actor) => 1 }, diff --git a/templates/chat-info-appel-au-moral.html b/templates/chat-info-appel-au-moral.html index e4c3605d..e73a1c5e 100644 --- a/templates/chat-info-appel-au-moral.html +++ b/templates/chat-info-appel-au-moral.html @@ -1,4 +1,4 @@ -{{#if useMoral}} +{{#if use.moral}} Vous avez fait appel {{#if (gt moral 0)}}au moral{{else}}à l'énergie du déspoir{{/if}} {{#if (eq perteMoralEchec 'dissolution')}}et échoué, cous marquez un point de dissolution!. diff --git a/templates/partial-roll-enctotal.html b/templates/partial-roll-enctotal.html index 15be1eec..19423295 100644 --- a/templates/partial-roll-enctotal.html +++ b/templates/partial-roll-enctotal.html @@ -1,6 +1,6 @@
diff --git a/templates/partial-roll-moral.html b/templates/partial-roll-moral.html index 9665368a..d148cac6 100644 --- a/templates/partial-roll-moral.html +++ b/templates/partial-roll-moral.html @@ -1,4 +1,4 @@ -
+