fatigue optionnelle #113

This commit is contained in:
Vincent Vandemeulebrouck
2021-05-08 20:08:56 +02:00
parent 11131e3b52
commit 51a3c4d04a
10 changed files with 97 additions and 86 deletions

View File

@ -10,8 +10,9 @@ import { Poetique } from "./poetique.js";
import { EffetsDraconiques } from "./tmr/effets-draconiques.js";
import { PixiTMR } from "./tmr/pixi-tmr.js";
import { Draconique } from "./tmr/draconique.js";
import { Grammar } from "./grammar.js";
import { Misc } from "./misc.js";
import { HtmlUtility } from "./html-utility.js";
import { ReglesOptionelles } from "./regles-optionelles.js";
/* -------------------------------------------- */
export class RdDTMRDialog extends Dialog {
@ -49,7 +50,7 @@ export class RdDTMRDialog extends Dialog {
this.actor = actor;
this.actor.tmrApp = this; // reference this app in the actor structure
this.viewOnly = tmrData.mode == "visu"
this.fatigueParCase = this.viewOnly ? 0 : this.actor.getTMRFatigue();
this.fatigueParCase = this.viewOnly || !ReglesOptionelles.isUsing("appliquer-fatigue") ? 0 : this.actor.getTMRFatigue();
this.cumulFatigue = 0;
this.loadRencontres();
this.loadSortsReserve();
@ -177,6 +178,7 @@ export class RdDTMRDialog extends Dialog {
async activateListeners(html) {
super.activateListeners(html);
HtmlUtility._showControlWhen($(".appliquerFatigue"), ReglesOptionelles.isUsing("appliquer-fatigue"));
document.getElementById("tmrrow1").insertCell(0).append(this.pixiApp.view);
if (this.viewOnly) {
@ -214,7 +216,9 @@ export class RdDTMRDialog extends Dialog {
// Gestion du cout de montée en points de rêve
let reveCout = ((this.tmrdata.isRapide && !EffetsDraconiques.isDeplacementAccelere(this.actor)) ? -2 : -1) - this.actor.countMonteeLaborieuse();
this.cumulFatigue += this.fatigueParCase;
if (ReglesOptionelles.isUsing("appliquer-fatigue")){
this.cumulFatigue += this.fatigueParCase;
}
await this.actor.reveActuelIncDec(reveCout);
// Le reste...
@ -245,9 +249,11 @@ export class RdDTMRDialog extends Dialog {
let refoulement = document.getElementById("tmr-refoulement-value");
refoulement.innerHTML = actorData.data.reve.refoulement.value;
let fatigueItem = document.getElementById("tmr-fatigue-table");
//console.log("Refresh : ", actorData.data.sante.fatigue.value);
fatigueItem.innerHTML = "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix(actorData.data.sante.fatigue.value, actorData.data.sante.endurance.max).html() + "</table>";
if (ReglesOptionelles.isUsing("appliquer-fatigue")){
let fatigueItem = document.getElementById("tmr-fatigue-table");
//console.log("Refresh : ", actorData.data.sante.fatigue.value);
fatigueItem.innerHTML = "<table class='table-fatigue'>" + RdDUtility.makeHTMLfatigueMatrix(actorData.data.sante.fatigue.value, actorData.data.sante.endurance.max).html() + "</table>";
}
}
/* -------------------------------------------- */
@ -333,7 +339,7 @@ export class RdDTMRDialog extends Dialog {
return true;
}
const resteAvantInconscience = this.actor.getFatigueMax() - this.actor.getFatigueActuelle() - this.cumulFatigue;
if (resteAvantInconscience <= 0) {
if (ReglesOptionelles.isUsing("appliquer-fatigue") && resteAvantInconscience <= 0) {
this._tellToGM("Vous vous écroulez de fatigue : vous quittez les Terres médianes !");
this.quitterLesTMRInconscient();
return true;
@ -408,7 +414,9 @@ export class RdDTMRDialog extends Dialog {
else if (rencData.rolled.isEchec && rencData.rencontre.isPersistant) {
setTimeout(() => {
rencData.nbRounds++;
this.cumulFatigue += this.fatigueParCase;
if (ReglesOptionelles.isUsing("appliquer-fatigue")){
this.cumulFatigue += this.fatigueParCase;
}
this._tentativeMaitrise(rencData);
this._deleteTmrMessages(rencData.actor, rencData.nbRounds);
}, 2000);
@ -916,7 +924,9 @@ export class RdDTMRDialog extends Dialog {
await this.actor.updateCoordTMR(tmr.coord);
this._updateDemiReve();
this.cumulFatigue += this.fatigueParCase;
if (ReglesOptionelles.isUsing("appliquer-fatigue")){
this.cumulFatigue += this.fatigueParCase;
}
this.updateValuesDisplay();
game.socket.emit("system.foundryvtt-reve-de-dragon", {
msg: "msg_tmr_move", data: {