diff --git a/module/actor.js b/module/actor.js
index 5132b08e..2bf54b4d 100644
--- a/module/actor.js
+++ b/module/actor.js
@@ -1490,12 +1490,14 @@ export class RdDActor extends Actor {
if (name == "endurance" && !this.isEntiteCauchemar()) {
if (result.newValue == 0 && inc < 0 && !options.isCritique) { // perte endurance et endurance devient 0 (sauf critique) -> -1 vie
sante.vie.value--;
+ result.perteVie = true;
}
result.newValue = Math.max(0, result.newValue);
if (inc > 0) { // le max d'endurance s'applique seulement à la récupération
result.newValue = Math.min(result.newValue, this._computeEnduranceMax())
}
const perte = compteur.value - result.newValue;
+ result.perte = perte;
if (perte > 1 && !options.ethylisme) {
// Peut-être sonné si 2 points d'endurance perdus d'un coup
const testIsSonne = await this.testSiSonne(sante, result.newValue);
@@ -1567,7 +1569,7 @@ export class RdDActor extends Actor {
}
/* -------------------------------------------- */
- async jetDeMoral(situation) {
+ async jetDeMoral(situation, messageReussi = undefined, messageManque = undefined) {
let jetMoral = new Roll("1d20").roll();
RdDDice.show(jetMoral);
let moralActuel = Misc.toInt(Misc.templateData(this).compteurs.moral.value);
@@ -1575,12 +1577,14 @@ export class RdDActor extends Actor {
const succes = jetMoral.total <= difficulte;
let ajustementMoral = this._calculAjustementMoral(succes, moralActuel, situation);
-
- await this.moralIncDec(ajustementMoral);
+ let defaultMessage = `Vous ${ajustementMoral > 0 ? "gagnez du moral" : ajustementMoral < 0 ? "perdez du moral" : "gardez votre moral"}.`;
+ let finMessage = succes ? (messageReussi != undefined ? messageReussi : defaultMessage) : (messageManque != undefined ? messageManque : defaultMessage);
+ let message = `Jet de moral ${succes ? "réussi" : "manqué"} en situation ${situation} (${jetMoral.total}/${difficulte}).
${finMessage}`;
ChatMessage.create({
whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name),
- content: `Jet de moral ${succes ? "réussi" : "manqué"} en situation ${situation} (${jetMoral.total}/${difficulte}), vous ${ajustementMoral > 0 ? "gagnez du moral" : ajustementMoral < 0 ? "perdez du moral" : "gardez votre moral"}`
+ content: message
});
+ await this.moralIncDec(ajustementMoral);
return ajustementMoral;
}
@@ -1630,7 +1634,7 @@ export class RdDActor extends Actor {
async jetEthylisme(forceAlcool = 0) {
const actorData = Misc.data(this);
let rollData = {
- vieValue: actorData.data.sante.vie.value,
+ vie: actorData.data.sante.vie.max,
forceAlcool: forceAlcool,
etat: this.getEtatGeneral({ ethylisme: true }),
diffNbDoses: -Number(actorData.data.compteurs.ethylisme.nb_doses || 0),
@@ -1648,54 +1652,68 @@ export class RdDActor extends Actor {
let ethylisme = duplicate(actorData.data.compteurs.ethylisme);
// Jet d'ethylisme
- let rollEthylisme = await RdDResolutionTable.roll(rollData.vieValue, rollData.finalLevel);
- let rollDataView = {
+ let rollEthylisme = await RdDResolutionTable.roll(rollData.vie, rollData.finalLevel);
+ let jetVieView = {
+ ethylismeEtape: 'Vie',
+ vie: rollData.vie,
forceAlcool: rollData.forceAlcool,
- rollEthylismeIsSuccess: rollEthylisme.isSuccess,
- rollEthylismeText: RdDResolutionTable.explain(rollEthylisme),
+ finalLevel: rollData.finalLevel,
+ jetVieSuccess: rollEthylisme.isSuccess,
+ jetVieText: RdDResolutionTable.explain(rollEthylisme),
};
if (rollEthylisme.isSuccess) {
ethylisme.nb_doses++;
- rollDataView.doses = ethylisme.nb_doses;
+ jetVieView.doses = ethylisme.nb_doses;
+
} else {
ethylisme.value = Math.max(ethylisme.value - 1, -7);
ethylisme.nb_doses = 0;
- rollDataView.doses = ethylisme.nb_doses;
- rollDataView.ajustementEthylique = ethylisme.value;
- rollDataView.nomEthylisme = RdDUtility.getNomEthylisme(ethylisme.value);
-
- let enduranceLost = new Roll("1d6").roll().total;
- rollDataView.enduranceLost = enduranceLost;
- await this.santeIncDec("endurance", -enduranceLost, {ethylisme:true});
- // Qui a bu boira (p 164)
- let rollVolonte = await RdDResolutionTable.roll(actorData.data.carac.volonte.value, Math.min(ethylisme.value, 0) + actorData.data.compteurs.moral.value);
- rollDataView.rollVolonteIsSuccess = rollVolonte.isSuccess;
- rollDataView.rollVolonteText = RdDResolutionTable.explain(rollVolonte);
+ jetVieView.doses = ethylisme.nb_doses;
+ jetVieView.ajustementEthylique = ethylisme.value;
+ jetVieView.nomEthylisme = RdDUtility.getNomEthylisme(ethylisme.value);
}
- RdDResolutionTable.displayRollData(rollDataView, this, 'chat-resultat-ethylisme.html');
+ RdDResolutionTable.displayRollData(jetVieView, this, 'chat-resultat-ethylisme.html');
if (rollEthylisme.isEchec) {
- await this._jetDeMoralEthylique(ethylisme);
- }
- await this.update({ 'data.compteurs.ethylisme': ethylisme });
- }
+ let enduranceLostRoll = new Roll("1d6").roll();
+ // enduranceLostRoll.showDice = true;
+ RdDDice.show(enduranceLostRoll);
+ let enduranceLost = enduranceLostRoll.total;
+ let perteEndurance = await this.santeIncDec("endurance", -enduranceLost, {ethylisme: true});
+ let jetEnduranceView = {
+ ethylismeEtape: 'Endurance',
+ enduranceLost: perteEndurance.perte,
+ perteVie: perteEndurance.perteVie,
+ };
+ RdDResolutionTable.displayRollData(jetEnduranceView, this, 'chat-resultat-ethylisme.html');
- /* -------------------------------------------- */
- async _jetDeMoralEthylique(ethylisme) {
- if (ethylisme.value >= -1 && !ethylisme.jet_moral) {
- let adjust = await this.jetDeMoral('heureuse');
- if (adjust > 0 || ethylisme.value == -1) {
- ethylisme.jet_moral = true;
- }
- if (ethylisme.value == -1 && adjust <= 0) {
- // alcool triste
- ChatMessage.create({
- content: "Décidément, vous avez l'alcool triste, vous perdez finalement un point de moral !",
- whisper: ChatUtility.getWhisperRecipientsAndGMs(game.user.name)
- });
- await this.moralIncDec(-1);
+ if (!ethylisme.jet_moral) {
+ let messageReussi = "L'alcool vous met en joie. Vous gagnez un point de moral";
+ let messageManque = "";
+ if (ethylisme.value == -1) {
+ messageManque = "Vous avez l'alcool triste. Vous perdez un point de moral.";
+ }
+ let adjust = await this.jetDeMoral('heureuse', messageReussi, messageManque);
+ if (adjust == 1) {
+ ethylisme.jet_moral = true;
+ } else if (ethylisme.value == -1) {
+ ethylisme.jet_moral = true;
+ await this.moralIncDec(-1);
+ }
}
+
+ // Qui a bu boira (p 164)
+ let rollVolonte = await RdDResolutionTable.roll(actorData.data.carac.volonte.value,
+ Math.min(ethylisme.value, 0) + actorData.data.compteurs.moral.value);
+ let jetVolonteView = {
+ ethylismeEtape: 'Volonte',
+ jetVolonteSuccess: rollVolonte.isSuccess,
+ jetVolonteText: RdDResolutionTable.explain(rollVolonte),
+ };
+ RdDResolutionTable.displayRollData(jetVolonteView, this, 'chat-resultat-ethylisme.html');
}
+
+ await this.update({'data.compteurs.ethylisme': ethylisme});
}
/* -------------------------------------------- */
diff --git a/module/rdd-roll-ethylisme.js b/module/rdd-roll-ethylisme.js
index 0b4e636e..bf61f6ed 100644
--- a/module/rdd-roll-ethylisme.js
+++ b/module/rdd-roll-ethylisme.js
@@ -55,7 +55,7 @@ export class RdDRollDialogEthylisme extends Dialog {
this.rollData.finalLevel = Number(this.rollData.etat) + Number(this.rollData.forceAlcool) + this.rollData.diffNbDoses;
// Mise à jour valeurs
- $("#roll-param").text(this.rollData.vieValue + " / " + Misc.toSignedString(this.rollData.finalLevel));
+ $("#roll-param").text(this.rollData.vie + " / " + Misc.toSignedString(this.rollData.finalLevel));
$(".table-resolution").remove();
}
diff --git a/module/rdd-utility.js b/module/rdd-utility.js
index 97c852f6..f8a81fa0 100644
--- a/module/rdd-utility.js
+++ b/module/rdd-utility.js
@@ -213,6 +213,7 @@ export class RdDUtility {
Handlebars.registerHelper('buildConteneur', (objet) => { return RdDUtility.buildConteneur(objet); });
Handlebars.registerHelper('caseTmr-label', coord => TMRUtility.getTMRLabel(coord));
Handlebars.registerHelper('caseTmr-type', coord => TMRUtility.getTMRType(coord));
+ Handlebars.registerHelper('equals', (a, b) => a == b);
return loadTemplates(templatePaths);
}
diff --git a/templates/chat-resultat-ethylisme.html b/templates/chat-resultat-ethylisme.html
index 232800d8..eeffdaa7 100644
--- a/templates/chat-resultat-ethylisme.html
+++ b/templates/chat-resultat-ethylisme.html
@@ -1,26 +1,39 @@
+{{#if (equals ethylismeEtape 'Vie')}}