Some checks failed
Release Creation / build (release) Failing after 56s
54 lines
1.6 KiB
JavaScript
54 lines
1.6 KiB
JavaScript
import CthulhuEternalItemSheet from "./base-item-sheet.mjs"
|
|
|
|
export default class CthulhuEternalSkillSheet extends CthulhuEternalItemSheet {
|
|
/** @override */
|
|
static DEFAULT_OPTIONS = {
|
|
classes: ["skill"],
|
|
position: {
|
|
width: 600,
|
|
},
|
|
window: {
|
|
contentClasses: ["skill-content"],
|
|
},
|
|
actions: {
|
|
rollProgress: CthulhuEternalSkillSheet.#onRollProgress,
|
|
},
|
|
|
|
}
|
|
|
|
/** @override */
|
|
static PARTS = {
|
|
main: {
|
|
template: "systems/fvtt-cthulhu-eternal/templates/skill.hbs",
|
|
},
|
|
}
|
|
|
|
/** @override */
|
|
async _prepareContext() {
|
|
const context = await super._prepareContext()
|
|
context.isGM = game.user.isGM
|
|
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
|
|
return context
|
|
}
|
|
|
|
static async #onRollProgress(event, target) {
|
|
console.log("Rolling progress for skill", this, event, target)
|
|
if (this.actor) {
|
|
const roll = await new Roll("1d4").evaluate()
|
|
if (roll) {
|
|
// Create a chat message with the roll result
|
|
const chatData = {
|
|
user: game.user.id,
|
|
speaker: ChatMessage.getSpeaker({ actor: this.actor }),
|
|
content: `<div class="progress-roll">${game.i18n.localize("CTHULHUETERNAL.Label.skillProgress")} - ${this.document.name} +${roll.total}</div>`,
|
|
type: CONST.CHAT_MESSAGE_TYPES.ROLL,
|
|
roll: roll,
|
|
};
|
|
await ChatMessage.create(chatData);
|
|
this.document.update( {"system.bonus" : this.document.system.bonus + roll.total, "system.rollFailed": false} )
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|