Merge branch 'marafal1/foundryvtt-reve-de-dragon-feature-ethylisme-refactor' into v1.4
This commit is contained in:
commit
06cbabb229
@ -1500,12 +1500,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);
|
||||
@ -1577,7 +1579,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);
|
||||
@ -1585,12 +1587,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;
|
||||
}
|
||||
|
||||
@ -1640,7 +1644,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),
|
||||
@ -1658,54 +1662,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});
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -214,6 +214,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);
|
||||
}
|
||||
|
@ -1,26 +1,39 @@
|
||||
{{#if (equals ethylismeEtape 'Vie')}}
|
||||
<h4>
|
||||
{{alias}} bois un verre d'alcool de force {{forceAlcool}}
|
||||
</h4>
|
||||
<hr>
|
||||
<hr/>
|
||||
<div>
|
||||
<span>
|
||||
{{{rollEthylismeText}}}
|
||||
{{{jetVieText}}}
|
||||
<br/>
|
||||
{{#if rollEthylismeIsSuccess}}
|
||||
{{#if jetVieSuccess}}
|
||||
Vous avez réussi votre jet d'éthylisme, vous avez consommé {{doses}} doses sans effet.
|
||||
{{else}}
|
||||
Vous avez échoué à votre jet d'éthylisme, vous êtes maintenant {{nomEthylisme}} ({{ajustementEthylique}}).
|
||||
<br/>
|
||||
Vous perdez {{enduranceLost}} points d'endurance.
|
||||
<br/>
|
||||
Qui a bu boira :
|
||||
{{{rollVolonteText}}}
|
||||
<br/>
|
||||
{{#if rollVolonteIsSuccess}}
|
||||
Vous êtes libre de continuer à boire ou pas.
|
||||
{{else}}
|
||||
Vous avez une envie irrépréssible de reprendre un verre
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if (equals ethylismeEtape 'Endurance')}}
|
||||
<div>
|
||||
<span>
|
||||
Vous perdez {{enduranceLost}} points d'endurance.
|
||||
{{#if perteVie}}<br/>Vous tombez inconscient et perdez un point de vie{{/if}}
|
||||
</span>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if (equals ethylismeEtape 'Volonte')}}
|
||||
<div>
|
||||
<span>
|
||||
Qui a bu boira :
|
||||
{{{jetVolonteText}}}
|
||||
<br/>
|
||||
{{#if jetVolonteSuccess}}
|
||||
Vous êtes libre de continuer à boire ou pas.
|
||||
{{else}}
|
||||
Vous avez une envie irrépressible de reprendre un verre.
|
||||
{{/if}}
|
||||
</span>
|
||||
</div>
|
||||
{{/if}}
|
@ -2,7 +2,7 @@
|
||||
<h2>Boire</h2>
|
||||
<img class="chat-icon" src="systems/foundryvtt-reve-de-dragon/icons/objets/chope_gres.webp" alt="Chope d'alcool"/>
|
||||
<div class="grid grid-2col">
|
||||
<label>Vie</label><label class="flexrow"> {{vieValue}}</label>
|
||||
<label>Vie</label><label class="flexrow"> {{vie}}</label>
|
||||
<label>Etat général</label><label class="flexrow">{{etat}}</label>
|
||||
<label>Déjà bu</label><label class="flexrow">{{diffNbDoses}}</label>
|
||||
<label>Force du breuvage</label>
|
||||
|
Loading…
Reference in New Issue
Block a user