Option pour état général hors éthylisme
Préparation pour les abus de nourriture et boissons
This commit is contained in:
parent
674582d6e8
commit
e8626f3566
@ -546,7 +546,7 @@ export class RdDActorSheet extends ActorSheet {
|
||||
this.render(true);
|
||||
});
|
||||
html.find('#ethylisme-test').click((event) => {
|
||||
this.actor.ethylismeTest();
|
||||
this.actor.jetEthylisme();
|
||||
this.render(true);
|
||||
});
|
||||
|
||||
|
@ -227,8 +227,14 @@ export class RdDActor extends Actor {
|
||||
return Misc.toInt(Misc.templateData(this).attributs.protection.value);
|
||||
}
|
||||
/* -------------------------------------------- */
|
||||
getEtatGeneral() {
|
||||
return Misc.toInt(Misc.templateData(this).compteurs.etat?.value);
|
||||
getEtatGeneral(options = { ethylisme: false }) {
|
||||
const tplData = Misc.templateData(this);
|
||||
let etatGeneral = Misc.toInt(tplData.compteurs.etat?.value);
|
||||
if (options.ethylisme) {
|
||||
// Pour les jets d'Ethylisme, on ignore le degré d'éthylisme (p.162)
|
||||
etatGeneral -= Math.min(0, tplData.compteurs.ethylisme.value);
|
||||
}
|
||||
return etatGeneral;
|
||||
}
|
||||
getMalusArmure() {
|
||||
return Misc.toInt(Misc.templateData(this).attributs?.malusarmure?.value);
|
||||
@ -1461,8 +1467,8 @@ export class RdDActor extends Actor {
|
||||
/* -------------------------------------------- */
|
||||
_calculAjustementMoral(succes, moral, situation) {
|
||||
switch (situation) {
|
||||
case 'heureuse': return succes ? 1 : 0;
|
||||
case 'malheureuse': return succes ? 0 : -1;
|
||||
case 'heureux': case 'heureuse': return succes ? 1 : 0;
|
||||
case 'malheureuse': case 'malheureux': return succes ? 0 : -1;
|
||||
case 'neutre':
|
||||
if (succes && moral <= 0) return 1;
|
||||
if (!succes && moral > 0) return -1;
|
||||
@ -1482,19 +1488,18 @@ export class RdDActor extends Actor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async ethylismeTest() {
|
||||
async jetEthylisme(forceAlcool = 0) {
|
||||
const actorData = Misc.data(this);
|
||||
let rollData = {
|
||||
vieValue: actorData.data.sante.vie.value,
|
||||
etat: this.getEtatGeneral() - Math.min(0, actorData.data.compteurs.ethylisme.value), // Pour les jets d'Ethylisme, on ignore le degré d'éthylisme (p.162)
|
||||
forceAlcool: forceAlcool,
|
||||
etat: this.getEtatGeneral({ ethylisme: true }),
|
||||
diffNbDoses: -Number(actorData.data.compteurs.ethylisme.nb_doses || 0),
|
||||
finalLevel: 0,
|
||||
diffConditions: 0,
|
||||
ajustementsConditions: CONFIG.RDD.ajustementsConditions,
|
||||
forceAlcool: 0
|
||||
diffConditions: 0
|
||||
}
|
||||
let html = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/dialog-roll-ethylisme.html', rollData);
|
||||
new RdDRollDialogEthylisme(html, rollData, this).render(true);
|
||||
new RdDRollDialogEthylisme(html, rollData, this, r => this.performEthylisme(r)).render(true);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -8,22 +8,27 @@ import { Misc } from "./misc.js";
|
||||
export class RdDRollDialogEthylisme extends Dialog {
|
||||
|
||||
/* -------------------------------------------- */
|
||||
constructor(html, rollData, actor) {
|
||||
|
||||
let myButtons = {
|
||||
rollButton: { label: "Test d'éthylisme", callback: html => this.actor.performEthylisme(this.rollData) }
|
||||
};
|
||||
|
||||
constructor(html, rollData, actor, onRoll) {
|
||||
// Common conf
|
||||
let dialogConf = { content: html, title: "Test d'éthylisme", buttons: myButtons, default: "rollButton" };
|
||||
let dialogConf = {
|
||||
title: "Test d'éthylisme",
|
||||
content: html,
|
||||
default: "rollButton",
|
||||
buttons: { "rollButton": { label: "Test d'éthylisme", callback: html => this.onButton(html) } }
|
||||
};
|
||||
let dialogOptions = { classes: ["rdddialog"], width: 400, height: 220, 'z-index': 99999 }
|
||||
super(dialogConf, dialogOptions)
|
||||
|
||||
//console.log("ETH", rollData);
|
||||
this.onRoll = onRoll;
|
||||
this.rollData = rollData;
|
||||
this.actor = actor;
|
||||
}
|
||||
|
||||
async onButton(html) {
|
||||
this.onRoll(this.rollData);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
Loading…
Reference in New Issue
Block a user