foundryvtt-beam-saber/module/blades-clock-sheet.js

70 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-11-04 12:37:28 +00:00
import { BladesSheet } from "./blades-sheet.js";
/**
* Extend the basic ActorSheet with some very simple modifications
* @extends {BladesSheet}
*/
export class BladesClockSheet extends BladesSheet {
/** @override */
static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["blades-in-the-dark", "sheet", "actor", "clock"],
2020-11-04 12:37:28 +00:00
template: "systems/blades-in-the-dark/templates/actors/clock-sheet.html",
2022-09-03 15:44:26 +00:00
width: 420,
height: 400,
2020-11-04 12:37:28 +00:00
});
}
/* -------------------------------------------- */
/** @override */
2022-09-03 15:44:26 +00:00
getData(options) {
const superData = super.getData( options );
const sheetData = superData.data;
sheetData.owner = superData.owner;
sheetData.editable = superData.editable;
sheetData.isGM = game.user.isGM;
return sheetData;
}
2020-11-04 12:37:28 +00:00
/* -------------------------------------------- */
/** @override */
async _updateObject(event, formData) {
2022-09-03 15:44:26 +00:00
let image_path = `systems/blades-in-the-dark/styles/assets/progressclocks-svg/Progress Clock ${formData['system.type']}-${formData['system.value']}.svg`;
2020-11-04 12:37:28 +00:00
formData['img'] = image_path;
2022-09-03 15:44:26 +00:00
formData['prototypeToken.texture.src'] = image_path;
let data = [];
let update = {
2020-11-04 12:37:28 +00:00
img: image_path,
width: 1,
height: 1,
scale: 1,
mirrorX: false,
mirrorY: false,
tint: "",
displayName: 50
};
let tokens = this.actor.getActiveTokens();
tokens.forEach( function( token ) {
data.push(
foundry.utils.mergeObject(
{ _id: token.id },
update
)
);
2020-11-04 12:37:28 +00:00
});
await TokenDocument.updateDocuments( data, { parent: game.scenes.current } )
2020-11-04 12:37:28 +00:00
// Update the Actor
return this.object.update(formData);
}
/* -------------------------------------------- */
}