#139 Jet d'Endurance

This commit is contained in:
sladecraven 2021-01-29 16:58:45 +01:00
parent e8af4ac813
commit f15067fff8
3 changed files with 32 additions and 4 deletions

View File

@ -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");

View File

@ -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 + "<br>";
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();

View File

@ -21,7 +21,7 @@
</li>
<li>
<label class="ctn-endu">
Endurance
<a id="jet-endurance">Endurance</a>
<a id="endurance-moins">-</a>
<input class="resource-content" type="text" name="data.sante.endurance.value" value="{{data.sante.endurance.value}}" data-dtype="Number"/>
<span>/ {{data.sante.endurance.max}}</span>