47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
import { renderTemplate } from "../constants.js"
|
|
|
|
export class DialogNouveauReposCD {
|
|
static prompt(actor) {
|
|
return new Promise((resolve) => {
|
|
const date = game.system.rdd.calendrier.dateCourante()
|
|
let moralChoisi = actor.system.sommeil?.moral ?? 'neutre'
|
|
const data = { name: actor.name, moral: moralChoisi }
|
|
|
|
renderTemplate(
|
|
"systems/foundryvtt-reve-de-dragon/templates/sommeil/dialog-nouveau-repos-cd.hbs",
|
|
data
|
|
).then(async (html) => {
|
|
const dialog = new Dialog({
|
|
title: "Château Dormant — " + actor.name,
|
|
content: html,
|
|
buttons: {
|
|
valider: {
|
|
label: "Valider le Château Dormant",
|
|
callback: ($html) => {
|
|
const stress = Number($html.find('input[name="cd-stress"]').val()) || 0
|
|
resolve({
|
|
stress: { valeur: stress, motif: `Nuit du ${date}` },
|
|
moral: moralChoisi
|
|
})
|
|
}
|
|
}
|
|
},
|
|
close: () => resolve({ stress: { valeur: 0, motif: `Nuit du ${date}` }, moral: 'neutre' })
|
|
}, {
|
|
width: 400,
|
|
height: 'fit-content',
|
|
'z-index': 99999
|
|
})
|
|
await dialog.render(true)
|
|
const $win = $(`#${dialog.id}`)
|
|
$win.find('.sommeil-actor-moral a').click((event) => {
|
|
const target = $(event.currentTarget)
|
|
moralChoisi = target.data('moral')
|
|
$win.find('.sommeil-actor-moral a i').removeClass('fa-solid').addClass('fa-regular')
|
|
target.find('i').removeClass('fa-regular').addClass('fa-solid')
|
|
})
|
|
})
|
|
})
|
|
}
|
|
}
|