|
|
|
@ -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}). <br/>${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.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.";
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
});
|
|
|
|
|
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});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
|