From 4b88efa9995639b2b772ce40574d837350ba104c Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sat, 6 Feb 2021 23:51:04 +0100 Subject: [PATCH] #150 : Gestion du cas Thanatos --- module/actor.js | 1 + module/item-competence.js | 5 +++++ module/item-sheet.js | 6 ++++++ module/rdd-utility.js | 12 +++++++++++- templates/item-competence-sheet.html | 2 +- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/module/actor.js b/module/actor.js index e466049d..4a076fd8 100644 --- a/module/actor.js +++ b/module/actor.js @@ -706,6 +706,7 @@ export class RdDActor extends Actor { } else { console.log("Competence not found", compName); } + RdDUtility.checkThanatosXP( compName ); } /* -------------------------------------------- */ diff --git a/module/item-competence.js b/module/item-competence.js index 8bd78974..deca47f1 100644 --- a/module/item-competence.js +++ b/module/item-competence.js @@ -59,10 +59,12 @@ export class RdDItemCompetence extends Item { static computeCompetenceXPCost(competence) { let xp = RdDItemCompetence.getDeltaXp(competence.data.base, competence.data.niveau ?? competence.data.base); xp += competence.data.xp ?? 0; + if ( competence.name.includes('Thanatos') ) xp *= 2; /// Thanatos compte double ! xp += competence.data.xp_sort ?? 0; return xp; } + /* -------------------------------------------- */ static computeEconomieCompetenceTroncXP(competences) { let economie = 0; for (let troncList of competenceTroncs) { @@ -87,17 +89,20 @@ export class RdDItemCompetence extends Item { return RdDItemCompetence.getCompetenceXp(niveau + 1); } + /* -------------------------------------------- */ static getCompetenceXp(niveau) { RdDItemCompetence._valideNiveau(niveau); return niveau < -10 ? 0 : competence_xp_par_niveau[niveau + 10]; } + /* -------------------------------------------- */ static getDeltaXp(from, to) { RdDItemCompetence._valideNiveau(from); RdDItemCompetence._valideNiveau(to); return competence_xp_cumul[to] - competence_xp_cumul[from]; } + /* -------------------------------------------- */ static _valideNiveau(niveau){ if (niveau < -11 || niveau > competence_niveau_max) { console.warn("Niveau en dehors des niveaux de compétences: [-11, " + competence_niveau_max + "]", niveau) diff --git a/module/item-sheet.js b/module/item-sheet.js index 54931c78..f70e3483 100644 --- a/module/item-sheet.js +++ b/module/item-sheet.js @@ -80,6 +80,12 @@ export class RdDItemSheet extends ItemSheet { // Select competence categorie html.find("#categorie").on("click", this._onClickSelectCategorie.bind(this) ); + html.find('#sheet-competence-xp').change((event) => { + if ( this.object.data.type == 'competence') { + RdDUtility.checkThanatosXP( this.object.data.name ); + } + } ); + html.find('#creer-tache-livre').click((event) => { let actorId = event.currentTarget.attributes['data-actor-id'].value; let actor = game.actors.get( actorId ); diff --git a/module/rdd-utility.js b/module/rdd-utility.js index 9d892c9f..db036798 100644 --- a/module/rdd-utility.js +++ b/module/rdd-utility.js @@ -1021,5 +1021,15 @@ export class RdDUtility { ui.notifications.warn("Pas d'heure de naissance selectionnée") } } - + + /* -------------------------------------------- */ + static checkThanatosXP(compName) { + if ( compName.includes('Thanatos') ) { + let message = "Vous avez mis des points d'Expérience dans la Voie de Thanatos !
Vous devez réduire manuellement d'un même montant d'XP une autre compétence Draconique."; + ChatMessage.create({ + whisper: ChatMessage.getWhisperRecipients(game.user.name), + content: message + }); + } + } } diff --git a/templates/item-competence-sheet.html b/templates/item-competence-sheet.html index 7d297780..17fefbb0 100644 --- a/templates/item-competence-sheet.html +++ b/templates/item-competence-sheet.html @@ -28,7 +28,7 @@
- +