diff --git a/module/actor.js b/module/actor.js index ce985271..66a9dedb 100644 --- a/module/actor.js +++ b/module/actor.js @@ -2315,15 +2315,17 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async _rollArt(artData, selected, oeuvre, callBackResult = r => this._resultArt(r)) { const actorData = Misc.data(this); - mergeObject(artData, { - oeuvre: oeuvre, - art: oeuvre.type, - competence: Misc.data(this.getCompetence(oeuvre.data.competence ?? artData.art)), - diffLibre: - (oeuvre.data.niveau ?? 0), - diffConditions: 0, - use: { libre: false, conditions: true }, - selectedCarac: duplicate(actorData.data.carac[selected]) - }); + mergeObject(artData, + { + oeuvre: oeuvre, + art: oeuvre.type, + competence: duplicate(Misc.data(this.getCompetence(oeuvre.data.competence ?? artData.art))), + diffLibre: - (oeuvre.data.niveau ?? 0), + diffConditions: 0, + use: { libre: false, conditions: true }, + selectedCarac: duplicate(actorData.data.carac[selected]) + }, + { overwrite: false }); artData.competence.data.defaut_carac = selected; if (!artData.forceCarac) { artData.forceCarac = {}; @@ -2366,13 +2368,13 @@ export class RdDActor extends Actor { const actorData = Misc.data(this); const artData = { art: 'danse', verbe: 'Danser', forceCarac: {} }; const oeuvre = duplicate(this.getItemOfType(id, artData.art)); - const selectedCarac = this._getCaracDanse(oeuvre); if (oeuvre.data.agilite) { artData.forceCarac['agilite'] = duplicate(actorData.data.carac.agilite); } if (oeuvre.data.apparence) { artData.forceCarac['apparence'] = duplicate(actorData.data.carac.apparence); } + const selectedCarac = this._getCaracDanse(oeuvre); await this._rollArt(artData, selectedCarac, oeuvre); } @@ -2434,12 +2436,21 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ async rollJeu(id) { + const actorData = Misc.data(this); + const oeuvre = Misc.data(this.getJeu(id)); + + const listCarac = oeuvre.data.caraccomp.toLowerCase().split(/[.,:\/-]/).map(it => it.trim()); + const carac = listCarac.length > 0 ? listCarac[0] : 'chance' const artData = { art: 'jeu', verbe: 'Jeu', use: { libre: true, conditions: true, }, + competence: duplicate(Misc.data(this.getCompetence('jeu'))), + forceCarac: {} }; - const oeuvre = duplicate(this.getJeu(id)); - await this._rollArt(artData, oeuvre.data?.caraccomp.toLowerCase() ?? 'chance', oeuvre); + listCarac.forEach(c => artData.forceCarac[c] = actorData.data.carac[c]); + artData.competence.data.niveauReel = artData.competence.data.niveau; + artData.competence.data.niveau = Math.max(artData.competence.data.niveau, oeuvre.data.base); + await this._rollArt(artData, carac, oeuvre); } async rollOeuvre(id) { @@ -2597,9 +2608,8 @@ export class RdDActor extends Actor { let xpComp = 0; if (competence) { xpComp = xp - xpCarac; - competence = duplicate(competence); - competence.data.xp = Misc.toInt(competence.data.xp) + xpComp; - await this.updateEmbeddedDocuments('Item', [competence]); + let update = { _id: competence.id, 'data.xp': Misc.toInt(competence.data.xp) + xpComp }; + await this.updateEmbeddedDocuments('Item', [update]); } else { xpCarac = Math.max(xpCarac, 1); } @@ -3202,24 +3212,33 @@ 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); + 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: 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})`; + 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, { @@ -3239,6 +3258,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..5d690f0c 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,16 @@ 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', + 'systems/foundryvtt-reve-de-dragon/templates/partial-select-carac.html', // Calendrier 'systems/foundryvtt-reve-de-dragon/templates/calendar-template.html', 'systems/foundryvtt-reve-de-dragon/templates/calendar-editor-template.html', diff --git a/styles/simple.css b/styles/simple.css index e5e83279..254dd5b0 100644 --- a/styles/simple.css +++ b/styles/simple.css @@ -528,6 +528,12 @@ section.sheet-body:after { text-align: left; width: 50px; } +.select-carac { + display: inline-block; + text-align: left; + width: 100%; + max-width: 90%; +} #vie-plus, #vie-moins, #endurance-plus, #endurance-moins, #fatigue-plus, #fatigue-moins, #ptreve-actuel-plus, #ptreve-actuel-moins, .monnaie-plus, .monnaie-moins { display: inline-block; diff --git a/templates/dialog-competence.html b/templates/dialog-competence.html index 5d7cebbf..46d45fec 100644 --- a/templates/dialog-competence.html +++ b/templates/dialog-competence.html @@ -1,17 +1,12 @@
-

+

+ {{competence.name}}
- - + + {{>"systems/foundryvtt-reve-de-dragon/templates/partial-select-carac.html"}}
{{#if arme}} {{#if attackerRoll}} @@ -63,47 +58,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..e813a9bf 100644 --- a/templates/dialog-roll-carac.html +++ b/templates/dialog-roll-carac.html @@ -1,32 +1,20 @@
-

-
- - - - - -
- - Sans appel au moral +

+ +
+
+
+
+ {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-surenc.html"}}
-
- {{>"systems/foundryvtt-reve-de-dragon/templates/dialog-roll-surenc.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-moral.html"}} +
+
+
+
diff --git a/templates/dialog-roll-chant.html b/templates/dialog-roll-chant.html index ad65341b..f9cd5a85 100644 --- a/templates/dialog-roll-chant.html +++ b/templates/dialog-roll-chant.html @@ -1,36 +1,26 @@ -
-
    -
  • -
  • -
-
- - Sans appel au moral +

Chanter: {{oeuvre.name}}

+ +
+
+ {{competence.name}} +
+ + +
+ {{> "systems/foundryvtt-reve-de-dragon/templates/chat-poesie.html" oeuvre.data}} +
+
+
+ + +
+ {{>"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-danse.html b/templates/dialog-roll-danse.html index dae51917..2134cb7a 100644 --- a/templates/dialog-roll-danse.html +++ b/templates/dialog-roll-danse.html @@ -1,47 +1,26 @@ -
-
    -
  • -
  • -
-
+

Danser: {{oeuvre.name}}

-
- - -
- - Sans appel au moral +
+
+ {{competence.name}} +
+ {{>"systems/foundryvtt-reve-de-dragon/templates/partial-select-carac.html"}} + +
+ {{> "systems/foundryvtt-reve-de-dragon/templates/chat-poesie.html" oeuvre.data}} +
+
+
+ + +
+ {{>"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-jeu.html b/templates/dialog-roll-jeu.html index c67bbcdc..c2195a4d 100644 --- a/templates/dialog-roll-jeu.html +++ b/templates/dialog-roll-jeu.html @@ -1,47 +1,25 @@ -
-
    -
  • -
  • -
  • -
  • -
-
-
- - -
- - Sans appel au moral +

Jouer à : {{oeuvre.name}}

+ +
+
+ {{competence.name}} +
+ + {{>"systems/foundryvtt-reve-de-dragon/templates/partial-select-carac.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-moral.html"}} +
-
- - - - -
+ {{> "systems/foundryvtt-reve-de-dragon/templates/chat-poesie.html" oeuvre.data}} -
-
diff --git a/templates/dialog-roll-maitrise-tmr.html b/templates/dialog-roll-maitrise-tmr.html index 31f65369..905ea1ec 100644 --- a/templates/dialog-roll-maitrise-tmr.html +++ b/templates/dialog-roll-maitrise-tmr.html @@ -14,7 +14,7 @@
- {{>"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-resolution.html b/templates/dialog-roll-resolution.html index bdaadae9..28573d76 100644 --- a/templates/dialog-roll-resolution.html +++ b/templates/dialog-roll-resolution.html @@ -1,29 +1,11 @@ -
- - - - - - +
+
+ + {{>"systems/foundryvtt-reve-de-dragon/templates/partial-select-carac.html"}} +
+ {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffLibre.html"}} + {{>"systems/foundryvtt-reve-de-dragon/templates/partial-roll-diffCondition.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..45a68528 --- /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..544a7bb5 --- /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 diff --git a/templates/partial-select-carac.html b/templates/partial-select-carac.html new file mode 100644 index 00000000..672a717d --- /dev/null +++ b/templates/partial-select-carac.html @@ -0,0 +1,7 @@ +