From 0ae77f68894f414de839238949637b016f146693 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 9 Apr 2021 01:03:51 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Fix=20xp=20des=20comp=C3=A9tences=20tronc?= =?UTF-8?q?=20#182?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit La méthode splice retourne les éléments supprimées, et non pas le tableau après suppression --- module/item-competence.js | 10 +++++----- module/misc.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/module/item-competence.js b/module/item-competence.js index 85d38ef6..03939d03 100644 --- a/module/item-competence.js +++ b/module/item-competence.js @@ -151,11 +151,11 @@ export class RdDItemCompetence extends Item { static computeEconomieXPTronc(competences) { return competenceTroncs.map( list => list.map(name => RdDItemCompetence.findCompetence(competences, name)) - // calcul du coût xp jusqu'au niveau 0 maximum - .map(it => RdDItemCompetence.computeDeltaXP(it?.data.base ?? -11, Math.min(it?.data.niveau ?? -11, 0))) - .sort(Misc.descending(x => x)) - .splice(0, 1) // ignorer le coût xp le plus élevé - .reduce(Misc.sum(), 0) + // calcul du coût xp jusqu'au niveau 0 maximum + .map(it => RdDItemCompetence.computeDeltaXP(it?.data.base ?? -11, Math.min(it?.data.niveau ?? -11, 0))) + .sort(Misc.ascending()) + .splice(0, list.length-1) // prendre toutes les valeurs sauf l'une des plus élevées + .reduce(Misc.sum(), 0) ).reduce(Misc.sum(), 0); } diff --git a/module/misc.js b/module/misc.js index c6e2597f..0661b44b 100644 --- a/module/misc.js +++ b/module/misc.js @@ -22,11 +22,11 @@ export class Misc { return (a, b) => a + b; } - static ascending(orderFunction) { + static ascending(orderFunction = x=>x) { return (a, b) => Misc.sortingBy(orderFunction(a), orderFunction(b)); } - static descending(orderFunction) { + static descending(orderFunction = x=>x) { return (a, b) => Misc.sortingBy(orderFunction(b), orderFunction(a)); } From 1f4523930c808289953cbd05a250dd8d70013f59 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 9 Apr 2021 01:05:32 +0200 Subject: [PATCH 2/2] =?UTF-8?q?class=20pour=20s=C3=A9lection=20par=20nom?= =?UTF-8?q?=20de=20champ?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/rdd-roll.js | 9 +++++---- templates/dialog-competence.html | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/module/rdd-roll.js b/module/rdd-roll.js index cbc8f5cd..b6d36add 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -219,14 +219,15 @@ export class RdDRoll extends Dialog { this.rollData.dmg.mortalite = event.currentTarget.checked ? "non-mortel" : "mortel"; this.updateRollResult(); }); - html.find('#tactique-combat').change((event) => { - this.rollData.tactique = event.currentTarget.value; - this.updateRollResult(); - }); html.find('.cuisine-proportions').change((event) => { this.rollData.proportions = Number(event.currentTarget.value); this.updateRollResult(); }); + html.find('.select-by-name').change((event) => { + const attribute = event.currentTarget.attributes['name'].value; + this.rollData[attribute] = event.currentTarget.value; + this.updateRollResult(); + }); html.find('.checkbox-by-name').change((event) => { const attribute = event.currentTarget.attributes['name'].value; this.rollData[attribute] = event.currentTarget.checked; diff --git a/templates/dialog-competence.html b/templates/dialog-competence.html index a2d55743..c4ba4d0e 100644 --- a/templates/dialog-competence.html +++ b/templates/dialog-competence.html @@ -50,7 +50,7 @@ {{else}} -