Fix: messages et insomnie
Amélioration des messages de sommeil (nombre d'heure, seulement les récupérations de rêve effectives, ...) Les insomnies ne durent bien que 12h draconique à partir du prochain chateau dormant (elles pouvaient durer 3 jours par erreur).
This commit is contained in:
@ -1,16 +1,13 @@
|
||||
import { EffetsDraconiques } from "../tmr/effets-draconiques.js";
|
||||
|
||||
export class DialogChateauDormant extends Dialog {
|
||||
|
||||
static async create() {
|
||||
const date = game.system.rdd.calendrier.dateCourante();
|
||||
const actorsSettings = game.actors.filter(actor => actor.hasPlayerOwner && actor.isPersonnage())
|
||||
.map(actor => ({
|
||||
actor: actor,
|
||||
insomnie: actor.system.sommeil?.insomnie,
|
||||
moral: 'neutre'
|
||||
}));
|
||||
const actors = game.actors.filter(actor => actor.hasPlayerOwner && actor.isPersonnage());
|
||||
|
||||
const dialogData = {
|
||||
actorsSettings,
|
||||
actors: actors,
|
||||
date: date,
|
||||
motifStress: `Nuit du ${date}`,
|
||||
finChateauDormant: game.system.rdd.calendrier.getTimestampFinChateauDormant()
|
||||
@ -65,44 +62,42 @@ export class DialogChateauDormant extends Dialog {
|
||||
const selected = this.html.find(event.currentTarget);
|
||||
const actorRow = selected.parents('.set-sommeil-actor');
|
||||
const actorId = actorRow.data('actor-id');
|
||||
const actorSetting = this.getActorSetting(actorId);
|
||||
if (actorSetting) {
|
||||
actorSetting.moral = selected.data('moral');
|
||||
const htmlMoral = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/sommeil/sommeil-actor-moral.hbs', actorSetting)
|
||||
actorRow.find('.sommeil-actor-moral').html(htmlMoral);
|
||||
// re-attach listeners for actor row
|
||||
this._activateListenerOnActorMoral(actorRow);
|
||||
}
|
||||
const actor = this.getActor(actorId);
|
||||
actor.system.sommeil.moral = selected.data('moral');
|
||||
const htmlMoral = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/sommeil/sommeil-actor-moral.hbs', actor.system.sommeil)
|
||||
actorRow.find('.sommeil-actor-moral').html(htmlMoral);
|
||||
// re-attach listeners for actor row
|
||||
this._activateListenerOnActorMoral(actorRow);
|
||||
}
|
||||
|
||||
getActorSetting(actorId) {
|
||||
return this.dialogData.actorsSettings.find(it => it.actor.id == actorId);
|
||||
getActor(actorId) {
|
||||
return this.dialogData.actors.find(it => it.id == actorId);
|
||||
}
|
||||
|
||||
async onChateauDormant() {
|
||||
const motifStress = this.html.find("form input[name='motifStress']").val();
|
||||
const sommeilActors = jQuery.map(this.html.find('li.set-sommeil-actor'), it => {
|
||||
const consignesChateauDormant = jQuery.map(this.html.find('li.set-sommeil-actor'), it => {
|
||||
const actorRow = this.html.find(it);
|
||||
const actorId = actorRow.data('actor-id');
|
||||
const actorSetting = this.getActorSetting(actorId);
|
||||
const actor = this.getActor(actorId);
|
||||
const insomnie = actorRow.find('input.sommeil-insomnie').is(':checked');
|
||||
return {
|
||||
actorId,
|
||||
actor,
|
||||
ignorer: actorRow.find('input.sommeil-ignorer').is(':checked'),
|
||||
stress: {
|
||||
motif: motifStress,
|
||||
valeur: Number.parseInt(actorRow.find('input.sommeil-stress').val()),
|
||||
},
|
||||
sommeil: {
|
||||
insomnie: actorRow.find('input.sommeil-insomnie').is(':checked'),
|
||||
heures: Number.parseInt(actorRow.find('input.sommeil-heures').val()),
|
||||
moral: actorSetting.moral,
|
||||
nouveaujour: true,
|
||||
date: this.dialogData.finChateauDormant,
|
||||
insomnie: insomnie,
|
||||
heures: insomnie ? 0 : Number.parseInt(actorRow.find('input.sommeil-heures').val()),
|
||||
moral: actor.moral,
|
||||
}
|
||||
}
|
||||
});
|
||||
await Promise.all(
|
||||
sommeilActors.filter(it => !it.ignorer)
|
||||
.map(async it => await game.actors.get(it.actorId)?.prepareChateauDormant(this.dialogData.finChateauDormant, it))
|
||||
)
|
||||
consignesChateauDormant.forEach(async consigne => await consigne.actor.prepareChateauDormant(consigne))
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
import { ReglesOptionelles } from "../settings/regles-optionelles.js";
|
||||
import { EffetsDraconiques } from "../tmr/effets-draconiques.js";
|
||||
|
||||
export class DialogRepos extends Dialog {
|
||||
|
||||
@ -6,7 +7,7 @@ export class DialogRepos extends Dialog {
|
||||
if (!ReglesOptionelles.isUsing("chateau-dormant-gardien")) {
|
||||
actor.system.sommeil = {
|
||||
"nouveaujour": true,
|
||||
"insomnie": false,
|
||||
"insomnie": EffetsDraconiques.isSujetInsomnie(actor),
|
||||
"moral": "neutre",
|
||||
"heures": 4
|
||||
}
|
||||
@ -58,7 +59,8 @@ export class DialogRepos extends Dialog {
|
||||
|
||||
async nuit() {
|
||||
await this.html.find("[name='sommeil.heures']").change();
|
||||
const sommeilHeures = Number.parseInt(await this.html.find("[name='sommeil.heures']").val());
|
||||
const val = await this.html.find("[name='sommeil.heures']").val();
|
||||
const sommeilHeures = Number.parseInt(val ?? '0');
|
||||
await this.actor.dormir(sommeilHeures, { chateauDormant: true });
|
||||
}
|
||||
|
||||
@ -72,7 +74,7 @@ export class DialogRepos extends Dialog {
|
||||
const selected = this.html.find(event.currentTarget);
|
||||
const parentDiv = selected.parents().find('.sommeil-actor-moral');
|
||||
const situationMoral = selected.data('moral');
|
||||
await this.actor.update({"system.sommeil.moral": situationMoral});
|
||||
await this.actor.setInfoSommeilMoral(situationMoral);
|
||||
const htmlMoral = await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/sommeil/sommeil-actor-moral.hbs', {
|
||||
moral: situationMoral
|
||||
});
|
||||
|
Reference in New Issue
Block a user