From 550f45d14cc9e8a13778f3a1a6e299e09be49bc6 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Tue, 20 Apr 2021 23:16:18 +0200 Subject: [PATCH] Rework dialog Alchimie --- module/actor.js | 45 ++++++++----- module/item.js | 6 ++ module/rdd-alchimie.js | 9 +++ module/rdd-roll.js | 4 +- module/rdd-utility.js | 10 ++- templates/dialog-competence.html | 47 ++++---------- templates/dialog-roll-alchimie.html | 65 +++++++++---------- templates/dialog-roll-carac.html | 4 +- templates/dialog-roll-maitrise-tmr.html | 2 +- templates/dialog-roll-reve-de-dragon.html | 2 +- ...nts.html => partial-roll-ajustements.html} | 0 templates/partial-roll-diffCondition.html | 10 +++ templates/partial-roll-diffLibre.html | 10 +++ ...ctotal.html => partial-roll-enctotal.html} | 0 templates/partial-roll-moral.html | 7 ++ ...l-surenc.html => partial-roll-surenc.html} | 0 16 files changed, 124 insertions(+), 97 deletions(-) rename templates/{dialog-roll-ajustements.html => partial-roll-ajustements.html} (100%) create mode 100644 templates/partial-roll-diffCondition.html create mode 100644 templates/partial-roll-diffLibre.html rename templates/{dialog-roll-enctotal.html => partial-roll-enctotal.html} (100%) create mode 100644 templates/partial-roll-moral.html rename templates/{dialog-roll-surenc.html => partial-roll-surenc.html} (100%) diff --git a/module/actor.js b/module/actor.js index ce985271..3c5e1014 100644 --- a/module/actor.js +++ b/module/actor.js @@ -3202,25 +3202,34 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - async effectuerTacheAlchimie(recetteId, alchimieName, alchimieData) { - let recette = this.getItemOfType(recetteId, 'recettealchimique'); + async effectuerTacheAlchimie(recetteId, tacheAlchimie, texteTache) { + let recetteData = Misc.data(this.getItemOfType(recetteId, 'recettealchimique')); const actorData = Misc.data(this); - if (recette) { - let competence = Misc.data(this.getCompetence("alchimie")); - let diffAlchimie = RdDAlchimie.getDifficulte(alchimieData); - let rollData = { - recette: recette, - competence: competence, - diffLibre: diffAlchimie // Per default at startup - } - if (alchimieName == "couleur") { - rollData.selectedCarac = actorData.data.carac.vue, - rollData.alchimieTexte = `Couleurs ${alchimieData} (${diffAlchimie}) (Malus de -4 si vous ne possédez pas de Cristal Alchimique)`; - } else { - rollData.selectedCarac = actorData.data.carac.dexterite, - rollData.alchimieTexte = `Consistances ${alchimieData} (${diffAlchimie})`; + if (recetteData) { + if (tacheAlchimie != "couleur" && tacheAlchimie != "consistance") { + ui.notifications.warn(`L'étape alchimique ${tacheAlchimie} - ${texteTache} est inconnue`); + return; } + const sansCristal = tacheAlchimie == "couleur" && this.data.items.filter(it => it.isCristalAlchimique()).length == 0; + const caracTache = RdDAlchimie.getCaracTache(tacheAlchimie); + const alchimieData = Misc.data(this.getCompetence("alchimie")); + + let rollData = { + recette: recetteData, + carac: { [caracTache]: actorData.data.carac[caracTache] }, + selectedCarac: actorData.data.carac[caracTache], + competence: alchimieData, + diffLibre: RdDAlchimie.getDifficulte(texteTache), + diffConditions: sansCristal ? -4 : 0, + alchimie: { + tache: Misc.upperFirst(tacheAlchimie), + texte: texteTache, + sansCristal: sansCristal + } + } + rollData.competence.data.defaut_carac = caracTache; + const dialog = await RdDRoll.create(this, rollData, { html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-alchimie.html', @@ -3239,6 +3248,10 @@ export class RdDActor extends Actor { } } + isCristalAlchimique(it) { + return it.type == 'objet' && Grammar.toLowerCaseNoAccent(it.name) == 'cristal alchimique' && it.data.quantite > 0; + } + /* -------------------------------------------- */ _alchimieResult(rollData) { RdDResolutionTable.displayRollData(rollData, this, 'chat-resultat-alchimie.html'); diff --git a/module/item.js b/module/item.js index 8c78388c..5259d4b5 100644 --- a/module/item.js +++ b/module/item.js @@ -33,6 +33,12 @@ export class RdDItem extends Item { isEquipement() { return RdDItem.getTypeObjetsEquipement().includes(Misc.data(this).type); } + + isCristalAlchimique() { + const itemData = Misc.data(this); + return itemData.type == 'objet' && Grammar.toLowerCaseNoAccent(itemData.name) == 'cristal alchimique' && itemData.data.quantite > 0; + } + getEnc() { const itemData = Misc.data(this); diff --git a/module/rdd-alchimie.js b/module/rdd-alchimie.js index 4fac68ac..58611457 100644 --- a/module/rdd-alchimie.js +++ b/module/rdd-alchimie.js @@ -53,4 +53,13 @@ export class RdDAlchimie { } return Math.min(0, -composantes); } + + static getCaracTache(tache) { + switch (tache) { + case "consistance": return 'dexterite'; + case "couleur": return 'vue'; + } + return 'intellect'; + } + } diff --git a/module/rdd-roll.js b/module/rdd-roll.js index 2ee9d7d9..943d4697 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -285,7 +285,7 @@ export class RdDRoll extends Dialog { HtmlUtility._showControlWhen($("#ajust-astrologique"), RdDResolutionTable.isAjustementAstrologique(rollData)); // Mise à jour valeurs - $("#compdialogTitle").text(this._getTitle(rollData)); + $(".dialog-roll-title").text(this._getTitle(rollData)); $('#coupsNonMortels').prop('checked', rollData.coupsNonMortels); $(".dmg-arme-actor").text(dmgText); $('.table-ajustement').remove(); @@ -299,7 +299,7 @@ export class RdDRoll extends Dialog { /* -------------------------------------------- */ async buildAjustements(rollData) { - const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/dialog-roll-ajustements.html`, rollData); + const html = await renderTemplate(`systems/foundryvtt-reve-de-dragon/templates/partial-roll-ajustements.html`, rollData); return html; } diff --git a/module/rdd-utility.js b/module/rdd-utility.js index bb5ed094..f384aef9 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -147,7 +147,6 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/niveau-ethylisme.html', 'systems/foundryvtt-reve-de-dragon/templates/casetmr-specific-list.html', // Dialogs - 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-ajustements.html', 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-resolution.html', 'systems/foundryvtt-reve-de-dragon/templates/dialog-competence.html', 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html', @@ -155,10 +154,15 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-encaisser.html', 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-meditation.html', 'systems/foundryvtt-reve-de-dragon/templates/dialog-tmr.html', - 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html', - 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-enctotal.html', 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-alchimie.html', 'systems/foundryvtt-reve-de-dragon/templates/dialog-astrologie-joueur.html', + // Partials + 'systems/foundryvtt-reve-de-dragon/templates/partial-roll-ajustements.html', + 'systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffLibre.html', + 'systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.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-moral.html', // Calendrier 'systems/foundryvtt-reve-de-dragon/templates/calendar-template.html', 'systems/foundryvtt-reve-de-dragon/templates/calendar-editor-template.html', diff --git a/templates/dialog-competence.html b/templates/dialog-competence.html index 5d7cebbf..1ed86065 100644 --- a/templates/dialog-competence.html +++ b/templates/dialog-competence.html @@ -1,5 +1,5 @@
-

+

@@ -63,47 +63,22 @@ {{/unless}} {{/if}} - {{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}} - {{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-enctotal.html"}} + {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-surenc.html"}} + {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-enctotal.html"}}
- +
+ {{#if attackerRoll}}
- {{#if attackerRoll}} - {{else}} - - - {{/if}} -
-
-
-
- - -
-
- -
- - Sans appel au moral -
-
-
+ {{else}} + {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffLibre.html"}} + {{/if}} + {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}} + {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}} +
diff --git a/templates/dialog-roll-alchimie.html b/templates/dialog-roll-alchimie.html index 325d530c..277f5af3 100644 --- a/templates/dialog-roll-alchimie.html +++ b/templates/dialog-roll-alchimie.html @@ -1,42 +1,35 @@ +{{log 'recette alchimique' this}} -
-
    -
  • -
  • -
  • -
-
- - Sans appel au moral +

Fabrication: {{recette.name}}

+
+
+ {{competence.name}} +
+ + + +
+
+
+
+ + +
+ {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.html"}} + {{#if alchimie.sansCristal}} +
+ + +
+ {{/if}} + {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-moral.html"}} +
+
-
-
- - - - -
- -
-
-
-
-
-
+
+
+ \ No newline at end of file diff --git a/templates/dialog-roll-carac.html b/templates/dialog-roll-carac.html index 588a6d98..45e58541 100644 --- a/templates/dialog-roll-carac.html +++ b/templates/dialog-roll-carac.html @@ -1,5 +1,5 @@
-

+

- {{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.html"}} + {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-surenc.html"}}
diff --git a/templates/dialog-roll-reve-de-dragon.html b/templates/dialog-roll-reve-de-dragon.html index 6b584c51..16433150 100644 --- a/templates/dialog-roll-reve-de-dragon.html +++ b/templates/dialog-roll-reve-de-dragon.html @@ -1,5 +1,5 @@ -

Rêve de Dragon de force {{rencontre.force}}!

+

Rêve de Dragon de force {{rencontre.force}}!

diff --git a/templates/dialog-roll-ajustements.html b/templates/partial-roll-ajustements.html similarity index 100% rename from templates/dialog-roll-ajustements.html rename to templates/partial-roll-ajustements.html diff --git a/templates/partial-roll-diffCondition.html b/templates/partial-roll-diffCondition.html new file mode 100644 index 00000000..0bc7fd18 --- /dev/null +++ b/templates/partial-roll-diffCondition.html @@ -0,0 +1,10 @@ +
+ + +
diff --git a/templates/partial-roll-diffLibre.html b/templates/partial-roll-diffLibre.html new file mode 100644 index 00000000..355141f9 --- /dev/null +++ b/templates/partial-roll-diffLibre.html @@ -0,0 +1,10 @@ +
+ + +
diff --git a/templates/dialog-roll-enctotal.html b/templates/partial-roll-enctotal.html similarity index 100% rename from templates/dialog-roll-enctotal.html rename to templates/partial-roll-enctotal.html diff --git a/templates/partial-roll-moral.html b/templates/partial-roll-moral.html new file mode 100644 index 00000000..2d268bac --- /dev/null +++ b/templates/partial-roll-moral.html @@ -0,0 +1,7 @@ +
+ +
+ + Sans appel au moral +
+
diff --git a/templates/dialog-roll-surenc.html b/templates/partial-roll-surenc.html similarity index 100% rename from templates/dialog-roll-surenc.html rename to templates/partial-roll-surenc.html