39 lines
1.0 KiB
JavaScript
39 lines
1.0 KiB
JavaScript
|
|
function createHealthDisplay() {
|
||
|
|
// Create a new application to display the health overview
|
||
|
|
class HealthOverview extends Application {
|
||
|
|
constructor() {
|
||
|
|
super();
|
||
|
|
}
|
||
|
|
|
||
|
|
static get defaultOptions() {
|
||
|
|
return mergeObject(super.defaultOptions, {
|
||
|
|
title: "Party Health Overview",
|
||
|
|
template: "modules/kyles-health-module/templates/health-overview.html",
|
||
|
|
width: 400,
|
||
|
|
height: "auto",
|
||
|
|
resizable: true
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
getData() {
|
||
|
|
const actors = game.actors.filter(a => a.hasPlayerOwner);
|
||
|
|
let data = actors.map(actor => {
|
||
|
|
let hp = actor.system.attributes.hp;
|
||
|
|
return {
|
||
|
|
name: actor.name,
|
||
|
|
current: hp.value,
|
||
|
|
max: hp.max,
|
||
|
|
};
|
||
|
|
});
|
||
|
|
return {
|
||
|
|
actors: data
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
new HealthOverview().render(true);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Run the function
|
||
|
|
createHealthDisplay();
|