Files
fvtt-ftl-nomad/module/applications/sheets/starship-sheet.mjs
LeRatierBretonnien 57eb9e76a4
All checks were successful
Release Creation / build (release) Successful in 1m40s
Add compendiums
2025-06-26 22:20:24 +02:00

113 lines
3.1 KiB
JavaScript

import FTLNomadActorSheet from "./base-actor-sheet.mjs"
export default class FTLNomadStarshipSheet extends FTLNomadActorSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["starship"],
position: {
width: 680,
height: 640,
},
window: {
contentClasses: ["starship-content"],
},
actions: {
},
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-ftl-nomad/templates/starship-main.hbs",
},
tabs: {
template: "templates/generic/tab-navigation.hbs",
},
description: {
template: "systems/fvtt-ftl-nomad/templates/starship-description.hbs",
},
}
/** @override */
tabGroups = {
sheet: "description",
}
/**
* Prepare an array of form header tabs.
* @returns {Record<string, Partial<ApplicationTab>>}
*/
#getTabs() {
const tabs = {
description: { id: "description", group: "sheet", icon: "fa-solid fa-book", label: "FTLNOMAD.Label.description" },
}
for (const v of Object.values(tabs)) {
v.active = this.tabGroups[v.group] === v.id
v.cssClass = v.active ? "active" : ""
}
return tabs
}
/** @override */
async _prepareContext() {
const context = await super._prepareContext()
context.tabs = this.#getTabs()
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.description, { async: true })
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.notes, { async: true })
context.enrichedModifications = await foundry.applications.ux.TextEditor.implementation.enrichHTML(this.document.system.modifications, { async: true })
return context
}
_generateTooltip(type, target) {
}
/** @override */
async _preparePartContext(partId, context) {
const doc = this.document
switch (partId) {
case "main":
break
case "description":
context.tab = context.tabs.description
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(doc.system.description, { async: true })
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(doc.system.notes, { async: true })
break
}
return context
}
async _onRoll(event, target) {
const rollType = $(event.currentTarget).data("roll-type")
let item
let formula
let roll
switch (rollType) {
case "starship-guns":
formula = this.actor.system.guns
// Rolll the damage
roll = new Roll(formula)
await roll.evaluate()
roll.toMessage( { flavor: `Starship ${this.actor.name} : Guns Damage` })
break
default:
throw new Error(`Unknown roll type ${rollType}`)
}
}
async _onDrop(event) {
if (!this.isEditable || !this.isEditMode) return
const data = TextEditor.getDragEventData(event)
// Handle different data types
switch (data.type) {
case "Item":
const item = await fromUuid(data.uuid)
return super._onDropItem(item)
}
}
}