forked from schultzcole/FVTT-Long-Rest-HD-Healing-5e
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnew-long-rest.js
49 lines (47 loc) · 2.06 KB
/
new-long-rest.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
export default class HDLongRestDialog extends dnd5e.applications.actor.ShortRestDialog {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
template: "modules/long-rest-hd-healing/templates/hd-long-rest.html",
classes: ["dnd5e", "dialog"],
});
}
getData() {
const data = super.getData();
const variant = game.settings.get("dnd5e", "restVariant");
const recoveryHDMultSetting = game.settings.get("long-rest-hd-healing", "recovery-mult");
data.promptNewDay = variant !== "gritty"; // It's always a new day when resting 1 week
data.newDay = variant === "normal"; // It's probably a new day when resting normally (8 hours)
// We'll autoroll if all hit dice are to be recovered.
if (recoveryHDMultSetting === "full") data.canRoll = false;
return data;
}
/** @returns {Promise<{ newDay: Boolean, }>} */
static async hdLongRestDialog({ actor } = {}) {
return new Promise((resolve, reject) => {
const dlg = new this(actor, {
title: game.i18n.localize("DND5E.LongRest"),
buttons: {
rest: {
icon: "<i class=\"fas fa-bed\"></i>",
label: game.i18n.localize("DND5E.Rest"),
callback: html => {
let newDay = true;
if (game.settings.get("dnd5e", "restVariant") !== "gritty") {
newDay = html.find("input[name=\"newDay\"]")[0].checked;
}
resolve(newDay);
},
},
cancel: {
icon: "<i class=\"fas fa-times\"></i>",
label: game.i18n.localize("Cancel"),
callback: reject,
},
},
default: "rest",
close: reject,
});
dlg.render(true);
});
}
}