diff --git a/module/actor-sheet.js b/module/actor-sheet.js
index ae6a0d3b..250e5bd5 100644
--- a/module/actor-sheet.js
+++ b/module/actor-sheet.js
@@ -483,6 +483,10 @@ export class RdDActorSheet extends ActorSheet {
this.actor.jetVie();
this.render(true);
});
+ html.find('#jet-endurance').click((event) => {
+ this.actor.jetEndurance();
+ this.render(true);
+ });
html.find('.monnaie-plus').click((event) => {
const li = $(event.currentTarget).parents(".item");
diff --git a/module/actor.js b/module/actor.js
index 1e3aaa73..b310de20 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -1107,15 +1107,13 @@ export class RdDActor extends Actor {
getSonne() {
return !this.isEntiteCauchemar() && (this.data.data.sante.sonne?.value ?? false);
}
-
async setSonne(sonne = true) {
if (this.isEntiteCauchemar()) {
return;
}
await this.setStatusSonne(sonne);
await this.setStateSonne(sonne);
- }
-
+ }
async setStateSonne(sonne) {
if (this.isEntiteCauchemar()) {
return;
@@ -1162,6 +1160,32 @@ export class RdDActor extends Actor {
return this.countBlessures(this.data.data.blessures[name].liste);
}
+ /* -------------------------------------------- */
+ async jetEndurance() {
+ let myRoll = new Roll("1d20").roll();
+ myRoll.showDice = true;
+ await RdDDice.show(myRoll);
+
+ let msgText = "Jet d'Endurance : " + myRoll.total + " / " + this.data.data.sante.endurance.value + "
";
+ if (myRoll.total == 1 || (myRoll.total != 20 && myRoll.total <= this.data.data.sante.endurance.value) ) {
+ msgText += `${this.name} a réussi son Jet d'Endurance !`;
+ if (myRoll.total == 1) {
+ msgText += `et gagne 1 Point d'Experience en Constitution`;
+ let constit = duplicate(this.data.data.carac.constitution)
+ constit.xp += 1;
+ await this.update({ "data.carac.constitution": constit });
+ }
+ } else {
+ msgText += `${this.name} a échoué son Jet d'Endurance et devient Sonné`;
+ await this.setSonne();
+ }
+ const message = {
+ content: msgText,
+ whisper: ChatMessage.getWhisperRecipients(game.user.name)
+ };
+ ChatMessage.create(message);
+ }
+
/* -------------------------------------------- */
async jetVie() {
let myRoll = new Roll("1d20").roll();
diff --git a/templates/actor-sheet.html b/templates/actor-sheet.html
index 22fe0081..ab276cab 100644
--- a/templates/actor-sheet.html
+++ b/templates/actor-sheet.html
@@ -21,7 +21,7 @@