From 7eb1d9f8382adb785fcde00f6f054cdf308d72ca Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 11 Jul 2023 02:34:05 +0200 Subject: [PATCH 1/3] Fix affichage Malus Armure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le malus armure est correctement affiché dans l'onglet caractéristiques. Il n'est plus stocké dans l'acteur mais calculé. --- module/actor-sheet.js | 1 + module/actor.js | 22 ++++++---------------- module/rdd-roll.js | 25 ------------------------- module/rolldata-ajustements.js | 2 +- template.json | 6 ------ templates/actor/carac-derivee.html | 2 +- 6 files changed, 9 insertions(+), 49 deletions(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 8a43be12..790a6b8e 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -57,6 +57,7 @@ export class RdDActorSheet extends RdDBaseActorSheet { resumeBlessures: this.actor.computeResumeBlessure(this.actor.system.blessures), caracTotal: RdDCarac.computeTotal(this.actor.system.carac, this.actor.system.beaute), surEncombrementMessage: this.actor.getMessageSurEncombrement(), + malusArmure: this.actor.getMalusArmure() }) this.timerRecherche = undefined; diff --git a/module/actor.js b/module/actor.js index a1866cdd..a909f8b4 100644 --- a/module/actor.js +++ b/module/actor.js @@ -95,7 +95,6 @@ export class RdDActor extends RdDBaseActor { this.computeIsHautRevant(); await this.cleanupConteneurs(); await this.computeEncTotal(); - await this.computeMalusArmure(); } /* -------------------------------------------- */ @@ -218,7 +217,12 @@ export class RdDActor extends RdDBaseActor { /* -------------------------------------------- */ getMalusArmure() { - return Misc.toInt(this.system.attributs?.malusarmure?.value) + if (this.isPersonnage()) { + return this.itemTypes[TYPES.armure].filter(it => it.system.equipe) + .map(it => it.system.malus) + .reduce(Misc.sum(), 0); + } + return 0; } /* -------------------------------------------- */ @@ -1142,20 +1146,6 @@ export class RdDActor extends RdDBaseActor { } } - - /* -------------------------------------------- */ - async computeMalusArmure() { - if (this.isPersonnage()) { - const malusArmure = this.filterItems(it => it.type == 'armure' && it.system.equipe) - .map(it => it.system.malus ?? 0) - .reduce(Misc.sum(), 0); - // Mise à jour éventuelle du malus armure - if (this.system.attributs?.malusarmure?.value != malusArmure) { - await this.updateAttributeValue("malusarmure", malusArmure); - } - } - } - /* -------------------------------------------- */ computeResumeBlessure() { const blessures = this.filterItems(it => it.system.gravite > 0, 'blessure') diff --git a/module/rdd-roll.js b/module/rdd-roll.js index 4331713a..6a65684e 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -305,7 +305,6 @@ export class RdDRoll extends Dialog { } RollDataAjustements.calcul(rollData, this.actor); - rollData.finalLevel = this._computeFinalLevel(rollData); const resolutionTable = await RdDResolutionTable.buildHTMLTable(RdDResolutionTable.subTable(rollData.caracValue, rollData.finalLevel)) const adjustements = await this.buildAjustements(rollData); @@ -330,30 +329,6 @@ export class RdDRoll extends Dialog { return await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/partial-roll-ajustements.html`, rollData); } - /* -------------------------------------------- */ - _computeFinalLevel(rollData) { - return RollDataAjustements.sum(rollData.ajustements); - } - /* -------------------------------------------- */ - _computeDiffCompetence(rollData) { - if (rollData.competence) { - return Misc.toInt(rollData.competence.system.niveau); - } - if (rollData.draconicList) { - return Misc.toInt(rollData.competence.system.niveau); - } - return 0; - } - - /* -------------------------------------------- */ - _computeMalusArmure(rollData) { - let malusArmureValue = 0; - if (rollData.malusArmureValue && (rollData.selectedCarac.label == "Agilité" || rollData.selectedCarac.label == "Dérobée")) { - malusArmureValue = rollData.malusArmureValue; - } - return malusArmureValue; - } - /* -------------------------------------------- */ _getTitle(rollData) { const carac = rollData.selectedCarac.label; diff --git a/module/rolldata-ajustements.js b/module/rolldata-ajustements.js index aa19a414..4d313a72 100644 --- a/module/rolldata-ajustements.js +++ b/module/rolldata-ajustements.js @@ -164,7 +164,7 @@ export class RollDataAjustements { descr: reference.getDescr && reference.getDescr(rollData, actor) } } - rollData.finalLevel = RollDataAjustements.sum(rollData.ajustements); + rollData.finalLevel = RollDataAjustements.sum(rollData.ajustements) } /* -------------------------------------------- */ diff --git a/template.json b/template.json index 9b0feb1c..22d08db3 100644 --- a/template.json +++ b/template.json @@ -393,12 +393,6 @@ "label": "Encombrement", "derivee": true }, - "malusarmure": { - "type": "number", - "value": 0, - "label": "Malus Armure", - "derivee": true - }, "protection": { "type": "number", "value": 0, diff --git a/templates/actor/carac-derivee.html b/templates/actor/carac-derivee.html index e955cb14..1fa900d8 100644 --- a/templates/actor/carac-derivee.html +++ b/templates/actor/carac-derivee.html @@ -72,7 +72,7 @@
  • - +
  • From 46401e5d6398c67d253aadcdd60a499b47bb2c51 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 11 Jul 2023 02:35:12 +0200 Subject: [PATCH 2/3] Cleanup: simplification _computeFinalLevel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit méthode supprimée dasn RdDRoll (car basée sur les ajustements), pas utile ici non plus. --- module/rdd-roll-resolution-table.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/module/rdd-roll-resolution-table.js b/module/rdd-roll-resolution-table.js index fcb456f9..9155af00 100644 --- a/module/rdd-roll-resolution-table.js +++ b/module/rdd-roll-resolution-table.js @@ -112,7 +112,7 @@ export class RdDRollResolutionTable extends Dialog { async updateRollResult() { let rollData = this.rollData; rollData.caracValue = parseInt(rollData.selectedCarac.value) - rollData.finalLevel = this._computeFinalLevel(rollData); + rollData.finalLevel = Misc.toInt(rollData.diffConditions) + Misc.toInt(rollData.diffLibre); const htmlTable = await RdDResolutionTable.buildHTMLTable({ carac: rollData.caracValue, @@ -129,12 +129,6 @@ export class RdDRollResolutionTable extends Dialog { } /* -------------------------------------------- */ - _computeFinalLevel(rollData) { - const diffConditions = Misc.toInt(rollData.diffConditions); - const diffLibre = Misc.toInt(rollData.diffLibre); - - return diffLibre + diffConditions; - } async close() { await super.close(); From a118dc7334846419b1a4fae2733ed8883fa4dff2 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 11 Jul 2023 02:53:34 +0200 Subject: [PATCH 3/3] Correction sur-Encombrement v2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le malus appliqué est maintenant correct. Avant, le malus pouvait avoir une virgule, et donc être arrondi dans le malus vraiment appliqué même si affiché correctement. --- module/actor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/actor.js b/module/actor.js index a909f8b4..ef356895 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1118,7 +1118,7 @@ export class RdDActor extends RdDBaseActor { case 'entite': case 'vehicule': return 0; } - return Math.min(0, this.getEncombrementMax() - Math.round(Number(this.getEncTotal()))); + return Math.min(0, Math.floor(this.getEncombrementMax() - this.encTotal)); } getMessageSurEncombrement() {