From ac77c6da9e0d92b94ab08bea72896e5ac1024547 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 2 Dec 2022 21:15:19 +0100 Subject: [PATCH 1/4] =?UTF-8?q?Fix=20calcul=20valeur=20=C3=A9quipement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/actor.js b/module/actor.js index 6b3c214a..edf43b10 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1362,7 +1362,7 @@ export class RdDActor extends Actor { const valeur = this.items.filter(it => it.isEquipement()) .map(it => it.valeurTotale()) .reduce(Misc.sum(), 0); - return valeur / 100; + return valeur; } /* -------------------------------------------- */ From 86f9c37b30b74e1b2e12b755afdba08d6a68835f Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 2 Dec 2022 21:20:37 +0100 Subject: [PATCH 2/4] =?UTF-8?q?Liste=20des=20milieux=20par=20d=C3=A9faut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/environnement.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/module/environnement.js b/module/environnement.js index 9130cd39..b26c9747 100644 --- a/module/environnement.js +++ b/module/environnement.js @@ -8,17 +8,16 @@ const RARETES = [ { name: 'Frequente', frequence: 18, min: 9, max: 36 }, { name: 'Rare', frequence: 6, min: 3, max: 12 }, { name: 'Rarissime', frequence: 2, min: 1, max: 4 }] +const DEFAULT_RARETE = 1; const SETTINGS_LISTE_MILIEUX = "liste-milieux"; const MILIEUX = [ "Collines", "Déserts", - "Désolations", "Forêts", - "Forêts Tropicales", "Marais", - "Milieux Aquatiques", - "Milieux Maritimes", + "Cours d'eau", + "Maritimes", "Montagnes", "Plaines", "Sous-Sols", @@ -46,7 +45,7 @@ export class Environnement { } static getRarete(name = undefined) { - return RARETES.find(it => it.name == name) ?? RARETES[0]; + return RARETES.find(it => it.name == name) ?? RARETES[DEFAULT_RARETE]; } static getFrequenceRarete(rarete, field = undefined) { @@ -67,7 +66,7 @@ export class Environnement { async findEnvironnementsLike(search) { const milieux = (await this.milieux()).filter(it => Grammar.includesLowerCaseNoAccent(it, search)); - if (milieux.length > 1){ + if (milieux.length > 1) { const milieuExact = milieux.find(it => Grammar.equalsInsensitive(it, search)); if (milieuExact) { return [milieuExact]; From 4b4d778d9cf16fdc74e68e3bf7dcec00d8105477 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 2 Dec 2022 21:21:21 +0100 Subject: [PATCH 3/4] =?UTF-8?q?Entr=C3=A9e=20ajoute=20le=20milieu=20aux=20?= =?UTF-8?q?fr=C3=A9quences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/environnement.js | 34 +++++++++++++++-------- templates/scripts/autocomplete-script.hbs | 1 - 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/module/environnement.js b/module/environnement.js index b26c9747..90ca00ba 100644 --- a/module/environnement.js +++ b/module/environnement.js @@ -150,21 +150,31 @@ export class EnvironmentSheetHelper { static activateListeners(sheet, html) { if (!sheet.options.editable) return; + html.find("input.input-selection-milieu").keypress(event => { + if (event.keyCode == '13') { + EnvironmentSheetHelper.onAddMilieu(html, sheet, event); + } + event.stopPropagation(); + }) html.find("a.milieu-add").click(event => EnvironmentSheetHelper.onAddMilieu(html, sheet, event)); html.find("div.environnement-milieu a.milieu-delete").click(event => EnvironmentSheetHelper.onDeleteMilieu(sheet, event)); html.find("div.environnement-milieu select.environnement-rarete").change(event => EnvironmentSheetHelper.onChange(sheet, event, - (updated) => { - const name = $(event.currentTarget).val(); - const rarete = Environnement.getRarete(name); - updated.rarete = rarete.name; - updated.frequence = Math.min( - Math.max(rarete.min, updated.frequence ?? rarete.frequence), - rarete.max); - })); + updated => EnvironmentSheetHelper.$changeRarete(event, updated))); html.find("div.environnement-milieu input[name='environnement-frequence']").change(event => EnvironmentSheetHelper.onChange(sheet, event, - (updated) => { - updated.frequence = Number($(event.currentTarget).val()) - })); + updated => EnvironmentSheetHelper.$changeFrequence(updated, event))); + } + + static $changeFrequence(updated, event) { + updated.frequence = Number($(event.currentTarget).val()); + } + + static $changeRarete(event, updated) { + const name = $(event.currentTarget).val(); + const rarete = Environnement.getRarete(name); + updated.rarete = rarete.name; + updated.frequence = Math.min( + Math.max(rarete.min, updated.frequence ?? rarete.frequence), + rarete.max); } static async onAddMilieu(html, sheet, event) { @@ -186,7 +196,7 @@ export class EnvironmentSheetHelper { static async onDeleteMilieu(sheet, event) { const milieu = EnvironmentSheetHelper.$getEventMilieu(event); - if (milieu) { + if (milieu != undefined) { const newList = sheet.item.system.environnement.filter(it => it.milieu != milieu) .sort(Misc.ascending(it => it.milieu)); await sheet.item.update({ 'system.environnement': newList }); diff --git a/templates/scripts/autocomplete-script.hbs b/templates/scripts/autocomplete-script.hbs index 7f918b6c..281565f9 100644 --- a/templates/scripts/autocomplete-script.hbs +++ b/templates/scripts/autocomplete-script.hbs @@ -81,7 +81,6 @@ function autocomplete(input, proposals) { currentFocus--; addActive(container); } else if (e.keyCode == 13) { - e.preventDefault(); if (currentFocus > -1 && container) { container[currentFocus].click(); } From 1276c64835a5995046010a6805c8bb9b0c1def8f Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 2 Dec 2022 21:22:43 +0100 Subject: [PATCH 4/4] Version 10.3.3 --- system.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system.json b/system.json index b6afe971..fbf21fe6 100644 --- a/system.json +++ b/system.json @@ -1,8 +1,8 @@ { "id": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", - "version": "10.3.2", - "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.3.2.zip", + "version": "10.3.3", + "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.3.3.zip", "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json", "compatibility": { "minimum": "10",