From 374b360afbba206691250f008fd619af601a8af6 Mon Sep 17 00:00:00 2001 From: sladecraven Date: Sun, 6 Dec 2020 21:39:55 +0100 Subject: [PATCH] =?UTF-8?q?#63=20Jet=20d'=C3=A9thylisme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor-sheet.js | 5 +++++ module/actor.js | 26 ++++++++++++++++++++++++++ templates/actor-sheet.html | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/module/actor-sheet.js b/module/actor-sheet.js index ad95fb49..dd0ccfab 100644 --- a/module/actor-sheet.js +++ b/module/actor-sheet.js @@ -389,6 +389,11 @@ export class RdDActorSheet extends ActorSheet { this.actor.ethylismeTest(); this.render(true); }); + + html.find('#jet-vie').click((event) => { + this.actor.jetVie(); + this.render(true); + }); html.find('#vie-plus').click((event) => { this.actor.santeIncDec("vie", 1); diff --git a/module/actor.js b/module/actor.js index 6079c2a5..5be795d4 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1055,6 +1055,32 @@ export class RdDActor extends Actor { { return blessuresListe.filter(b => b.active).length } + + /* -------------------------------------------- */ + async jetVie() { + let myRoll = new Roll("1d20").roll(); + myRoll.showDice = true; + await RdDDice.show(myRoll); + + let msgText = "Jet de Vie : " + myRoll.total + " / " + this.data.data.sante.vie.value + "
"; + if ( myRoll.total <= this.data.data.sante.vie.value ) { + msgText += "Jet réussi, pas de perte de point de vie (prochain jet dans 1 round pour 1 critique, SC minutes pour une grave)"; + if ( myRoll.total == 1) { + msgText += "La durée entre 2 jets de vie est multipliée par 20 (20 rounds pour une critique, SCx20 minutes pour une grave)"; + } + } else { + msgText += "Jet échoué, vous perdez 1 point de vie"; + await this.santeIncDec("vie", -1); + if ( myRoll.total == 20) { + msgText += "Votre personnage est mort !!!!!"; + } + } + const message = { + content: msgText, + whisper: ChatMessage.getWhisperRecipients(game.user.name) + }; + ChatMessage.create(message); + } /* -------------------------------------------- */ async santeIncDec(name, inc, isCritique = false) { diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html index 4d3889df..c0b12d6d 100644 --- a/templates/actor-sheet.html +++ b/templates/actor-sheet.html @@ -11,7 +11,7 @@