From 045ee76013a37f8979d628e774df4ed2016ff242 Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 17 Feb 2023 01:29:21 +0100 Subject: [PATCH] =?UTF-8?q?Fix:=20transfert=20du=20moral=20=C3=A0=20chatea?= =?UTF-8?q?u=20dormant?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/sommeil/dialog-chateau-dormant.js | 48 ++++++++++++------------ 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/module/sommeil/dialog-chateau-dormant.js b/module/sommeil/dialog-chateau-dormant.js index 33ce5a28..49faa706 100644 --- a/module/sommeil/dialog-chateau-dormant.js +++ b/module/sommeil/dialog-chateau-dormant.js @@ -1,4 +1,3 @@ -import { EffetsDraconiques } from "../tmr/effets-draconiques.js"; export class DialogChateauDormant extends Dialog { @@ -76,28 +75,31 @@ export class DialogChateauDormant extends Dialog { async onChateauDormant() { const motifStress = this.html.find("form input[name='motifStress']").val(); - 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 actor = this.getActor(actorId); - const insomnie = actorRow.find('input.sommeil-insomnie').is(':checked'); - return { - actor, - ignorer: actorRow.find('input.sommeil-ignorer').is(':checked'), - stress: { - motif: motifStress, - valeur: Number.parseInt(actorRow.find('input.sommeil-stress').val()), - }, - sommeil: { - nouveaujour: true, - date: this.dialogData.finChateauDormant, - insomnie: insomnie, - heures: insomnie ? 0 : Number.parseInt(actorRow.find('input.sommeil-heures').val()), - moral: actor.moral, - } - } - }); - consignesChateauDormant.forEach(async consigne => await consigne.actor.prepareChateauDormant(consigne)) + jQuery.map( + this.html.find('li.set-sommeil-actor'), + it => this.extractConsigneActor(this.html.find(it), motifStress) + ).forEach(async consigne => await consigne.actor.prepareChateauDormant(consigne)) } + + extractConsigneActor(actorRow, motifStress) { + const actorId = actorRow.data('actor-id'); + const actor = this.getActor(actorId); + const insomnie = actorRow.find('input.sommeil-insomnie').is(':checked'); + return { + actor, + ignorer: actorRow.find('input.sommeil-ignorer').is(':checked'), + stress: { + motif: motifStress, + valeur: Number.parseInt(actorRow.find('input.sommeil-stress').val()), + }, + sommeil: { + nouveaujour: true, + date: this.dialogData.finChateauDormant, + insomnie: insomnie, + heures: insomnie ? 0 : Number.parseInt(actorRow.find('input.sommeil-heures').val()), + moral: actor.system.sommeil.moral ?? 'neutre', + } + }; + } } \ No newline at end of file