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,34 +8,39 @@ 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 dialogOptions = { classes: ["rdddialog"], width: 400, height: 220, 'z-index': 99999 }
|
||||
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);
|
||||
|
||||
|
||||
this.bringToTop(); // Ensure top level
|
||||
// Get the rollData stuff
|
||||
var rollData = this.rollData;
|
||||
|
||||
function updateRollResult(rollData) {
|
||||
|
||||
|
||||
rollData.finalLevel = Number(rollData.etat) + Number(rollData.forceAlcool) + rollData.diffNbDoses;
|
||||
|
||||
|
||||
// Mise à jour valeurs
|
||||
$("#roll-param").text(rollData.vieValue + " / " + Misc.toSignedString(rollData.finalLevel));
|
||||
$(".table-resolution").remove();
|
||||
@ -47,7 +52,7 @@ export class RdDRollDialogEthylisme extends Dialog {
|
||||
$("#forceAlcool").val(Misc.toInt(rollData.forceAlcool));
|
||||
updateRollResult(rollData);
|
||||
});
|
||||
|
||||
|
||||
// Update !
|
||||
html.find('#forceAlcool').change((event) => {
|
||||
rollData.forceAlcool = Misc.toInt(event.currentTarget.value); // Update the selected bonus/malus
|
||||
|
Loading…
Reference in New Issue
Block a user