diff --git a/module/actor-sheet.js b/module/actor-sheet.js index 10324999..7cbcc9f0 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -299,6 +299,11 @@ export class RdDActorSheet extends ActorSheet { let tacheId = li.data('item-id'); this.actor.rollTache( tacheId ); }); + html.find('.meditation-label a').click((event) => { + const li = $(event.currentTarget).parents(".item"); + let meditationId = li.data('item-id'); + this.actor.rollMeditation( meditationId ); + }); // Points de reve actuel html.find('.ptreve-actuel a').click((event) => { diff --git a/module/actor.js b/module/actor.js index 8197574e..63267ae2 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1708,7 +1708,7 @@ export class RdDActor extends Actor { } /* -------------------------------------------- */ - getTache ( id ) { + getTacheMeditation ( id ) { return this.data.items.find( item => item._id == id ); } @@ -1757,6 +1757,60 @@ export class RdDActor extends Actor { this.updateEmbeddedEntity( "OwnedItem", rollData.tache); } + /* -------------------------------------------- */ + async rollMeditation( id ) { + let meditation = duplicate( this.getTacheMeditation( id ) ); + let competence = duplicate(this.getCompetence(meditation.data.competence)); + competence.data.defaut_carac = "intellect"; // Meditation = tjs avec intellect + let meditationData = { + competence: competence, + meditation: meditation, + diffConditions: 0, + editLibre: false, + editConditions: true, + isHeure: false, + isVeture: false, + isComportement: false, + isPurification: false, + carac : { } + }; + meditationData.carac["intellect"] = duplicate(this.data.data.carac["intellect"]); + + console.log("rollMedittion !!!", meditationData); + + const dialog = await RdDRoll.create(this, meditationData, {html: 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-meditation.html'}, { + name: 'jet-meditation', + label: 'Jet de Meditation ' + meditation.name, + height: 600, + callbacks: [ + this.createCallbackExperience(), + { condition: r=> r.rolled.isETotal, action: r => this._meditationETotal(r)}, + { action: r => this._meditationResult(r) } + ] + } ); + dialog.render(true); + } + + /* -------------------------------------------- */ + async _meditationResult(meditationData) { + this.santeIncDec( "fatigue", 2); + + meditationData.diffLecture = -7; + if (meditationData.rolled.isPart ) + meditationData.diffLecture = 0; + else if (meditationData.rolled.isSign ) + meditationData.diffLecture = -3; + + RdDResolutionTable.displayRollData(meditationData, this.name, 'chat-resultat-meditation.html'); + } + + + /* -------------------------------------------- */ + _meditationETotal(meditationData) { + meditationData.meditation.data.malus--; + this.updateEmbeddedEntity( "OwnedItem", meditationData.meditation); + } + /* -------------------------------------------- */ async _competenceResult(rollData) { RdDResolutionTable.displayRollData(rollData, this.name, 'chat-resultat-competence.html') diff --git a/module/rdd-resolution-table.js b/module/rdd-resolution-table.js index 7789a8c4..b113b872 100644 --- a/module/rdd-resolution-table.js +++ b/module/rdd-resolution-table.js @@ -223,6 +223,7 @@ export class RdDResolutionTable { return duplicate(RdDResolutionTable.resolutionTable[caracValue][difficulte + 10]); } + /* -------------------------------------------- */ static isAjustementAstrologique(rollData) { if (rollData.selectedCarac && rollData.selectedCarac.label.toLowerCase().includes('chance')) { return true; diff --git a/module/rdd-roll.js b/module/rdd-roll.js index 793a5493..31ff9a14 100644 --- a/module/rdd-roll.js +++ b/module/rdd-roll.js @@ -218,12 +218,44 @@ export class RdDRoll extends Dialog { this.rollData.useMalusEncTotal = event.currentTarget.checked; updateRollResult(rollData); }); + // Section Méditation + html.find('#isHeure').change((event) => { + this.rollData.isHeure = event.currentTarget.checked; + updateRollResult(rollData); + }); + html.find('#isPurification').change((event) => { + this.rollData.isPurification = event.currentTarget.checked; + updateRollResult(rollData); + }); + html.find('#isVeture').change((event) => { + this.rollData.isVeture = event.currentTarget.checked; + updateRollResult(rollData); + }); + html.find('#isComportement').change((event) => { + this.rollData.isComportement = event.currentTarget.checked; + updateRollResult(rollData); + }); + } + /* -------------------------------------------- */ _isIgnoreEtatGeneral(rollData) { return rollData.selectedCarac.ignoreEtatGeneral; } + /* -------------------------------------------- */ + _computeDiffMeditation( rollData ) { + let diff = 0; + if ( rollData.meditation ) { + diff = (!rollData.isHeure) ? diff - 2 : diff; + diff = (!rollData.isVeture) ? diff - 2 : diff; + diff = (!rollData.isComportement) ? diff - 2 : diff; + diff = (!rollData.isisPuritication) ? diff - 2 : diff; + diff = diff - rollData.meditation.data.malus; // Malus permanent éventuel + } + return diff; + } + /* -------------------------------------------- */ _computeFinalLevel(rollData) { const etat = this._isIgnoreEtatGeneral(rollData) ? 0 : Misc.toInt(rollData.etat); @@ -235,13 +267,15 @@ export class RdDRoll extends Dialog { // Gestion malus armure const malusArmureValue = this._computeMalusArmure(rollData); + const diffMeditation = this._computeDiffMeditation( rollData ); const diffLibre = this._computeDiffLibre(rollData); const diffCompetence = this._computeDiffCompetence(rollData); const diffMoral = rollData.selectedCarac == this.actor.data.data.carac.volonte ? rollData.moral : 0; - return etat + diffCompetence + diffLibre + diffMoral + diffConditions + malusEnc + malusEncTotal + malusArmureValue + ajustementChance + bonusTactique; + return etat + diffCompetence + diffLibre + diffMoral + diffConditions + malusEnc + malusEncTotal + malusArmureValue + diffMeditation + ajustementChance + bonusTactique; } + /* -------------------------------------------- */ _computeDiffCompetence(rollData) { if (rollData.competence) { return Misc.toInt(rollData.competence.data.niveau); @@ -252,6 +286,7 @@ export class RdDRoll extends Dialog { return 0; } + /* -------------------------------------------- */ _computeDiffLibre(rollData) { let diffLibre = Misc.toInt(rollData.diffLibre); if (rollData.draconicList && rollData.selectedSort) { diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 7487755a..79edee9c 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -188,6 +188,7 @@ export class RdDUtility { 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-carac.html', 'systems/foundryvtt-reve-de-dragon/templates/dialog-roll-sort.html', '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', diff --git a/sounds/progession_xp.ogg b/sounds/progession_xp.ogg new file mode 100644 index 00000000..3dfc555f Binary files /dev/null and b/sounds/progession_xp.ogg differ diff --git a/templates/chat-resultat-meditation.html b/templates/chat-resultat-meditation.html new file mode 100644 index 00000000..0fea9f11 --- /dev/null +++ b/templates/chat-resultat-meditation.html @@ -0,0 +1,15 @@ +

+ {{alias}} a médité : {{meditation.name}} +

+{{> "systems/foundryvtt-reve-de-dragon/templates/chat-infojet.html"}} +
+
+ {{#if rolled.isSuccess}} + {{alias}} aperçoit un signe Draconique fugitif, qu'il faut aller lire en {{meditation.data.tmr}} en réussissant un test d'INTELLECT/Draconic à {{diffLecture}}. + Selon le résultat de votre lecture, vous gagnerez les points suivants en Sort: 3 pour une Normale, 5 pour une Significative, 10 pour une Particulière. + {{else}} + {{alias}} a échoué dans sa méditation et ne voit aucun signe Draconique. + {{/if}} +
Vous vous êtes fatigué de 2 cases. + {{#if rolled.isETotal}}
Votre échec total augmente de 1 la difficulté de la méditation!{{/if~}} +
diff --git a/templates/dialog-roll-meditation.html b/templates/dialog-roll-meditation.html new file mode 100644 index 00000000..8a169720 --- /dev/null +++ b/templates/dialog-roll-meditation.html @@ -0,0 +1,66 @@ +
+
+ +
+ +
+ +
+
+ + +
+ + + + +
+ + + +
+
+
+
+
+
+ + diff --git a/templates/item-meditation-sheet.html b/templates/item-meditation-sheet.html index f3b35075..083b0e44 100644 --- a/templates/item-meditation-sheet.html +++ b/templates/item-meditation-sheet.html @@ -28,8 +28,8 @@
- + {{#select item.data.heure}} {{>"systems/foundryvtt-reve-de-dragon/templates/heures-select-option.html"}} {{/select}}