#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.actor.jetVie();
this.render(true); this.render(true);
}); });
html.find('#jet-endurance').click((event) => {
this.actor.jetEndurance();
this.render(true);
});
html.find('.monnaie-plus').click((event) => { html.find('.monnaie-plus').click((event) => {
const li = $(event.currentTarget).parents(".item"); const li = $(event.currentTarget).parents(".item");

View File

@ -1107,15 +1107,13 @@ export class RdDActor extends Actor {
getSonne() { getSonne() {
return !this.isEntiteCauchemar() && (this.data.data.sante.sonne?.value ?? false); return !this.isEntiteCauchemar() && (this.data.data.sante.sonne?.value ?? false);
} }
async setSonne(sonne = true) { async setSonne(sonne = true) {
if (this.isEntiteCauchemar()) { if (this.isEntiteCauchemar()) {
return; return;
} }
await this.setStatusSonne(sonne); await this.setStatusSonne(sonne);
await this.setStateSonne(sonne); await this.setStateSonne(sonne);
} }
async setStateSonne(sonne) { async setStateSonne(sonne) {
if (this.isEntiteCauchemar()) { if (this.isEntiteCauchemar()) {
return; return;
@ -1162,6 +1160,32 @@ export class RdDActor extends Actor {
return this.countBlessures(this.data.data.blessures[name].liste); 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() { async jetVie() {
let myRoll = new Roll("1d20").roll(); let myRoll = new Roll("1d20").roll();

View File

@ -21,7 +21,7 @@
</li> </li>
<li> <li>
<label class="ctn-endu"> <label class="ctn-endu">
Endurance <a id="jet-endurance">Endurance</a>
<a id="endurance-moins">-</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"/> <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> <span>/ {{data.sante.endurance.max}}</span>