From 702af3796138cb3dcbf35c388d8bdf30f02e330a Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 18 Nov 2022 23:00:37 +0100 Subject: [PATCH 1/5] Cleanup --- module/migrations.js | 6 +++--- module/rdd-calendrier.js | 3 +-- templates/dialog-roll-competence.html | 2 +- templates/dialog-roll-signedraconique.html | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/module/migrations.js b/module/migrations.js index f04c9e43..7997e1c1 100644 --- a/module/migrations.js +++ b/module/migrations.js @@ -104,7 +104,7 @@ class _10_0_33_MigrationNomsDraconic extends Migration { get version() { return "10.0.33"; } migrationNomDraconic(ancien) { - if (typeof ancien == 'string'){ + if (typeof ancien == 'string') { switch (ancien) { case 'oniros': case "Voie d'Oniros": return "Voie d'Oniros"; case 'hypnos': case "Voie d'Hypnos": return "Voie d'Hypnos"; @@ -122,8 +122,8 @@ class _10_0_33_MigrationNomsDraconic extends Migration { await this.applyItemsUpdates(items => items .filter(it => ["sort", "sortreserve"].includes(it.type) - && (typeof it.system.draconic == 'string') || (typeof it.system.draconic?.name == 'string')) - .map(it => { return { _id: it.id, "system.draconic": this.migrationNomDraconic(it.system.draconic)} })); + && (typeof it.system.draconic == 'string') || (typeof it.system.draconic?.name == 'string')) + .map(it => { return { _id: it.id, "system.draconic": this.migrationNomDraconic(it.system.draconic) } })); } } diff --git a/module/rdd-calendrier.js b/module/rdd-calendrier.js index 151cdfde..68ab4f76 100644 --- a/module/rdd-calendrier.js +++ b/module/rdd-calendrier.js @@ -118,7 +118,7 @@ export class RdDCalendrier extends Application { this.listeNombreAstral = this.getListeNombreAstral(); this.rebuildListeNombreAstral(false); // Ensure always up-to-date } - console.log(this.calendrier, this.calendrierPos, this.listeNombreAstral); + console.log('RdDCalendrier.constructor()', this.calendrier, this.calendrierPos, this.listeNombreAstral); } /* -------------------------------------------- */ @@ -217,7 +217,6 @@ export class RdDCalendrier extends Application { /* -------------------------------------------- */ async rebuildListeNombreAstral(showDice = SHOW_DICE) { if (Misc.isUniqueConnectedGM()) { - console.log("rebuildListeNombreAstral", showDice); let jourCourant = this.getCurrentDayIndex(); let newList = []; for (let i = 0; i < MAX_NOMBRE_ASTRAL; i++) { diff --git a/templates/dialog-roll-competence.html b/templates/dialog-roll-competence.html index 0e33f2a9..110368e1 100644 --- a/templates/dialog-roll-competence.html +++ b/templates/dialog-roll-competence.html @@ -19,7 +19,7 @@
- diff --git a/templates/dialog-roll-signedraconique.html b/templates/dialog-roll-signedraconique.html index a0bc0423..0894eae8 100644 --- a/templates/dialog-roll-signedraconique.html +++ b/templates/dialog-roll-signedraconique.html @@ -1,4 +1,4 @@ -
+

Lire le signe draconique {{#select system.competence}} - {{>"systems/foundryvtt-reve-de-dragon/templates/enum-competence.html"}} + + {{>"systems/foundryvtt-reve-de-dragon/templates/enum-competence.html" categorie='melee'}} {{/select}}

@@ -15,8 +16,17 @@ + +
+ +
-- 2.35.3 From 5565bb7a48cc5ae0250f3be757da2fbf03480115 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 19 Nov 2022 01:35:01 +0100 Subject: [PATCH 3/5] Fix des malus encombrement --- module/actor.js | 4 ++++ module/rdd-roll.js | 21 +++++++++++++++++---- module/rolldata-ajustements.js | 6 +++--- templates/partial-roll-enctotal.html | 6 ++---- templates/partial-roll-surenc.html | 6 ++---- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/module/actor.js b/module/actor.js index ee28c6f1..6632412a 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1280,6 +1280,10 @@ export class RdDActor extends Actor { await item.delete(); } + isSurenc() { + return this.isPersonnage() ? (this.system.compteurs.surenc.value < 0) : false + } + /* -------------------------------------------- */ computeMalusSurEncombrement() { switch (this.type) { diff --git a/module/rdd-roll.js b/module/rdd-roll.js index e41587e3..3c10fcad 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -50,14 +50,16 @@ export class RdDRoll extends Dialog { diffConditions: 0, diffLibre: rollData.competence?.system.default_diffLibre ?? 0, malusArmureValue: actor.getMalusArmure(), - surencMalusFlag: actor.isPersonnage() ? (actorData.compteurs.surenc.value < 0) : false, surencMalusValue: actor.computeMalusSurEncombrement(), - useMalusSurenc: false, 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: { libre: true, conditions: true, surenc: false, encTotal: false }, + use: { + libre: true, + conditions: true, + surenc: false, + encTotal: false + }, isMalusEncombrementTotal: rollData.competence ? RdDItemCompetence.isMalusEncombrementTotal(rollData.competence) : 0, - useMalusEncTotal: false, encTotal: actor.getEncTotal(), ajustementAstrologique: actor.ajustementAstrologique(), surprise: actor.getSurprise(false), @@ -244,6 +246,14 @@ export class RdDRoll extends Dialog { this.rollData[attribute] = event.currentTarget.checked; this.updateRollResult(); }); + html.find('input.use-encTotal').change((event) => { + this.rollData.use.encTotal = event.currentTarget.checked; + this.updateRollResult(); + }); + html.find('input.use-surenc').change((event) => { + this.rollData.use.surenc = event.currentTarget.checked; + this.updateRollResult(); + }); html.find('.appel-moral').click((event) => { /* l'appel au moral, qui donne un bonus de +1 */ this.rollData.useMoral = !this.rollData.useMoral; const appelMoral = html.find('.icon-appel-moral')[0]; @@ -286,6 +296,7 @@ export class RdDRoll extends Dialog { $(".div-sort-ptreve-fixe").text(sort.system.ptreve); const diffVariable = RdDItemSort.isDifficulteVariable(sort); const coutVariable = RdDItemSort.isCoutVariable(sort); + HtmlUtility._showControlWhen($(".div-sort-non-rituel"), !sort.system.isrituel); HtmlUtility._showControlWhen($(".div-sort-difficulte-var"), diffVariable); HtmlUtility._showControlWhen($(".div-sort-difficulte-fixe"), !diffVariable); @@ -318,6 +329,8 @@ 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($(".diffMoral"), rollData.ajustements.moralTotal.used); HtmlUtility._showControlWhen($(".divAppelAuMoral"), rollData.use.appelAuMoral); HtmlUtility._showControlWhen($("#etat-general"), !RdDCarac.isIgnoreEtatGeneral(rollData)); diff --git a/module/rolldata-ajustements.js b/module/rolldata-ajustements.js index 2807065a..1824c60c 100644 --- a/module/rolldata-ajustements.js +++ b/module/rolldata-ajustements.js @@ -63,13 +63,13 @@ export const referenceAjustements = { }, encTotal: { isVisible: (rollData, actor) => RdDItemCompetence.isMalusEncombrementTotal(rollData.competence), - isUsed: (rollData, actor) => rollData.useMalusEncTotal, + isUsed: (rollData, actor) => rollData.use.encTotal, getLabel: (rollData, actor) => 'Encombrement total', getValue: (rollData, actor) => -actor.getEncTotal() }, surenc: { - isVisible: (rollData, actor) => rollData.useMalusSurenc, - isUsed: (rollData, actor) => rollData.useMalusSurenc, + isVisible: (rollData, actor) => actor.isSurenc(), + isUsed: (rollData, actor) => rollData.use.surenc, getLabel: (rollData, actor) => 'Sur-encombrement', getValue: (rollData, actor) => actor.computeMalusSurEncombrement() }, diff --git a/templates/partial-roll-enctotal.html b/templates/partial-roll-enctotal.html index dfe959d0..15be1eec 100644 --- a/templates/partial-roll-enctotal.html +++ b/templates/partial-roll-enctotal.html @@ -1,8 +1,6 @@ -{{#if ajustements.encTotal.visible}} -
+
-{{/if}} diff --git a/templates/partial-roll-surenc.html b/templates/partial-roll-surenc.html index 0f59e227..421e7752 100644 --- a/templates/partial-roll-surenc.html +++ b/templates/partial-roll-surenc.html @@ -1,8 +1,6 @@ -{{#if surencMalusFlag}} -
+
-{{/if}} -- 2.35.3 From 3362f2473a5a82a0ca1166ffc33ee83389e5b272 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 19 Nov 2022 01:37:00 +0100 Subject: [PATCH 4/5] =?UTF-8?q?Jet=20de=20Carac=20avec=20comp=C3=A9tence?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pour faire plus rapidement les jets depuis les caracs --- module/actor.js | 5 ++++- module/rdd-roll.js | 5 +++++ module/rdd-utility.js | 1 + templates/dialog-roll-carac.html | 2 ++ templates/partial-roll-competences.html | 8 ++++++++ 5 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 templates/partial-roll-competences.html diff --git a/module/actor.js b/module/actor.js index 6632412a..5e91f3c7 100644 --- a/module/actor.js +++ b/module/actor.js @@ -2471,7 +2471,10 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async rollCarac(caracName) { - let rollData = { selectedCarac: this.getCaracByName(caracName) }; + let rollData = { + selectedCarac: this.getCaracByName(caracName), + competences: this.itemTypes['competence'] + }; const dialog = await RdDRoll.create(this, rollData, { html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html' }, diff --git a/module/rdd-roll.js b/module/rdd-roll.js index 3c10fcad..836bce49 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -217,6 +217,11 @@ export class RdDRoll extends Dialog { this.updateRollResult(); $("#diffLibre").val(this.rollData.diffLibre); }); + html.find('.roll-carac-competence').change((event) => { + const competence = event.currentTarget.value; + this.rollData.competence = this.rollData.competences.find(it => it.name == competence); + this.updateRollResult(); + }); html.find('.roll-signedraconique').change((event) => { let sortKey = Misc.toInt(event.currentTarget.value); this.setSelectedSigneDraconique(this.rollData.signes[sortKey]); diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 7f99fc45..636487a0 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -222,6 +222,7 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/partial-roll-enctotal.html', 'systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html', 'systems/foundryvtt-reve-de-dragon/templates/partial-roll-forcer.html', + 'systems/foundryvtt-reve-de-dragon/templates/partial-roll-competences.html', 'systems/foundryvtt-reve-de-dragon/templates/partial-select-carac.html', 'systems/foundryvtt-reve-de-dragon/templates/partial-item-description.html', // Dialogs diff --git a/templates/dialog-roll-carac.html b/templates/dialog-roll-carac.html index 89c454ab..d2f3e5dc 100644 --- a/templates/dialog-roll-carac.html +++ b/templates/dialog-roll-carac.html @@ -5,7 +5,9 @@
+ {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-competences.html"}} {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-surenc.html"}} + {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-enctotal.html"}}
{{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffLibre.html"}} diff --git a/templates/partial-roll-competences.html b/templates/partial-roll-competences.html new file mode 100644 index 00000000..9d13235d --- /dev/null +++ b/templates/partial-roll-competences.html @@ -0,0 +1,8 @@ +
+ + +
-- 2.35.3 From 424cdd3e65319bdbdb781a8fba6f95f143888d2e Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Sat, 19 Nov 2022 01:49:38 +0100 Subject: [PATCH 5/5] v10.2.5 --- system.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system.json b/system.json index 14f982a1..030ce210 100644 --- a/system.json +++ b/system.json @@ -1,8 +1,8 @@ { "id": "foundryvtt-reve-de-dragon", "title": "Rêve de Dragon", - "version": "10.2.4", - "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.2.4.zip", + "version": "10.2.5", + "download": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/archive/foundryvtt-reve-de-dragon-10.2.5.zip", "manifest": "https://www.uberwald.me/gitea/public/foundryvtt-reve-de-dragon/raw/v10/system.json", "compatibility": { "minimum": "10", -- 2.35.3