From 793036d2b8807170186a6750f0db35f36f905fd3 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Fri, 27 Nov 2020 12:20:13 +0100 Subject: [PATCH] =?UTF-8?q?#44=20-=20Gestion=20sur=20encombrement=20corrig?= =?UTF-8?q?=C3=A9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor-sheet.js | 2 +- module/actor.js | 27 ++++++++++++++++------- module/rdd-roll-dialog.js | 15 +++++++++++-- module/rdd-utility.js | 4 +++- system.json | 4 ++-- template.json | 14 +++++++++++- templates/actor-humanoide-sheet.html | 16 +++++++++----- templates/actor-inventaire-conteneur.html | 6 ++--- templates/actor-sheet.html | 16 +++++++++----- templates/dialog-competence.html | 1 + templates/dialog-roll-carac.html | 1 + templates/dialog-roll-surenc.html | 6 +++++ 12 files changed, 83 insertions(+), 29 deletions(-) create mode 100644 templates/dialog-roll-surenc.html diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 12f5330b..379dab5d 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -91,7 +91,6 @@ export class RdDActorSheet extends ActorSheet { // Mise à jour de l'encombrement total this.actor.computeEncombrementTotal(); - // Common data data.data.competenceByCategory = data.competenceByCategory; data.data.encombrementTotal = this.actor.encombrementTotal; @@ -112,6 +111,7 @@ export class RdDActorSheet extends ActorSheet { RdDUtility.filterItemsPerTypeForSheet(data ); data.data.sortReserve = data.data.reve.reserve.list; RdDUtility.buildArbreDeConteneur( this, data ); + data.data.surEncombrementMessage = (data.data.compteurs.surenc.value < 0) ? "Sur-Encombrement!" : ""; return data; } diff --git a/module/actor.js b/module/actor.js index 73f8ef0d..2cc84446 100644 --- a/module/actor.js +++ b/module/actor.js @@ -723,7 +723,7 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - computeEtatGeneral( ) + computeEtatGeneral( ) { let data = this.data.data; // Pas d'état général pour les entités forçage à 0 @@ -732,12 +732,14 @@ export class RdDActor extends Actor { return; } // Pour les autres - let state = 0; + let state = 0, surenc = 0; state = state - (data.sante.vie.max - data.sante.vie.value); if (data.sante.fatigue) // Creatures n'ont pas de fatigue state = state + RdDUtility.currentFatigueMalus(data.sante.fatigue.value, data.sante.endurance.max); - state = state - this.detectSurEncombrement(); - data.compteurs.etat.value = state; + state = state; + surenc = -this.detectSurEncombrement(); + data.compteurs.etat.value = state; + data.compteurs.surenc.value = surenc; } /* -------------------------------------------- */ @@ -1081,8 +1083,11 @@ export class RdDActor extends Actor { diffLibre: sortList[0].data.difficulte, // Per default at startup coutreve: Array(20).fill().map((item, index) => 1 + index), ajustementsConditions: CONFIG.RDD.ajustementsConditions, - difficultesLibres: CONFIG.RDD.difficultesLibres - } + difficultesLibres: CONFIG.RDD.difficultesLibres, + surencMalusFlag: false, // A ne pas utiliser pour les sorts + surencMalusValue: 0, + surencMalusApply: false + } let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html', rollData); new RdDRollDialog("sort", html, rollData, this ).render(true); } @@ -1106,7 +1111,10 @@ export class RdDActor extends Actor { etat: this.data.data.compteurs.etat.value, finalLevel: 0, diffConditions: 0, - diffLibre: 0 + diffLibre: 0, + surencMalusFlag: (this.data.data.compteurs.surenc.value < 0), + surencMalusValue: this.data.data.compteurs.surenc.value, + surencMalusApply: false } console.log(caracName, rollData); let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html', rollData); @@ -1179,7 +1187,10 @@ export class RdDActor extends Actor { diffLibre: (attackerRoll) ? attackerRoll.diffLibre : 0, attackerRoll: attackerRoll, finalLevel: 0, - coupsNonMortels: false + coupsNonMortels: false, + surencMalusFlag: (this.data.data.compteurs.surenc.value < 0), + surencMalusValue: this.data.data.compteurs.surenc.value, + surencMalusApply: false } if ( competence.type == 'competencecreature') { // Specific case for Creatures diff --git a/module/rdd-roll-dialog.js b/module/rdd-roll-dialog.js index 057d60db..45e099b4 100644 --- a/module/rdd-roll-dialog.js +++ b/module/rdd-roll-dialog.js @@ -142,9 +142,19 @@ export class RdDRollDialog extends Dialog { console.log("RdDRollDialog - Cout reve", ptreve); updateRollResult(rollData); }); + html.find('#ptreve-variable').change((event) => { + let ptreve = Misc.toInt(event.currentTarget.value); + this.rollData.selectedSort.data.ptreve_reel = ptreve; // Update the selectedCarac + console.log("RdDRollDialog - Cout reve", ptreve); + updateRollResult(rollData); + }); html.find('#coupsNonMortels').change((event) => { this.rollData.mortalite = event.currentTarget.checked ? "non-mortel" : "non-mortel"; }); + html.find('#surencMalusApply').change((event) => { + this.rollData.surencMalusApply = event.currentTarget.checked; + updateRollResult(rollData); + }); } /* -------------------------------------------- */ @@ -152,14 +162,15 @@ export class RdDRollDialog extends Dialog { let etat = Misc.toInt(rollData.etat); const diffLibre = Misc.toInt(rollData.diffLibre); const diffConditions = Misc.toInt(rollData.diffConditions); + let malusEnc = (rollData.surencMalusApply ) ? rollData.surencMalusValue : 0; if (rollData.competence) { - return etat + Misc.toInt(rollData.competence.data.niveau) + diffLibre + diffConditions; + return etat + Misc.toInt(rollData.competence.data.niveau) + diffLibre + diffConditions + malusEnc; } if (rollData.draconicList) { let diffSort = (rollData.selectedSort.data.difficulte.toLowerCase() == "variable") ? diffLibre : Misc.toInt(rollData.selectedSort.data.difficulte); return etat + Misc.toInt(rollData.selectedDraconic.data.niveau) + diffSort + diffConditions; } - return etat + diffLibre + diffConditions; + return etat + diffLibre + diffConditions + malusEnc; } /* -------------------------------------------- */ diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 8832296d..12ea3735 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -149,6 +149,8 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html', 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html', 'systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html', + 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html', + // Calendrier 'systems/foundryvtt-reve-de-dragon/templates/calendar-template.html', // Conteneur/item in Actor sheet @@ -237,7 +239,7 @@ export class RdDUtility { if (!niveau) niveau = 1; let str = Handlebars.partials['systems/foundryvtt-reve-de-dragon/templates/actor-inventaire-conteneur.html']( { item: objet} ); if (objet.type == 'conteneur') { - str = str + "