128 lines
5.6 KiB
JavaScript
128 lines
5.6 KiB
JavaScript
import VermineBaseActorSheet from "./base-actor-sheet.mjs"
|
|
|
|
export default class VermineCharacterSheetV2 extends VermineBaseActorSheet {
|
|
|
|
static DEFAULT_OPTIONS = {
|
|
classes: ["character"],
|
|
position: { width: 860, height: 720 },
|
|
window: { contentClasses: ["character-content"] },
|
|
actions: {
|
|
addSpecialty: VermineCharacterSheetV2.#onAddSpecialty,
|
|
openExperiencePhase: VermineCharacterSheetV2.#onOpenExperiencePhase,
|
|
openLearning: VermineCharacterSheetV2.#onOpenLearning
|
|
}
|
|
}
|
|
|
|
static PARTS = {
|
|
main: { template: "systems/vermine2047/templates/actor/appv2/character-main.hbs", scrollable: [""] },
|
|
tabs: { template: "templates/generic/tab-navigation.hbs" },
|
|
abilities: { template: "systems/vermine2047/templates/actor/appv2/character-abilities.hbs", scrollable: [""] },
|
|
totem: { template: "systems/vermine2047/templates/actor/appv2/character-totem.hbs", scrollable: [""] },
|
|
equipment: { template: "systems/vermine2047/templates/actor/appv2/character-equipment.hbs", scrollable: [""] },
|
|
stories: { template: "systems/vermine2047/templates/actor/appv2/character-stories.hbs", scrollable: [""] },
|
|
combat: { template: "systems/vermine2047/templates/actor/appv2/character-combat.hbs", scrollable: [""] },
|
|
experience: { template: "systems/vermine2047/templates/actor/appv2/character-experience.hbs", scrollable: [""] }
|
|
}
|
|
|
|
tabGroups = { sheet: "abilities" }
|
|
|
|
#getTabs() {
|
|
const tabs = {
|
|
abilities: { id: "abilities", group: "sheet", icon: "fas fa-address-card", label: "VERMINE.tabs.abilities" },
|
|
totem: { id: "totem", group: "sheet", icon: "fas fa-star", label: "VERMINE.tabs.totem" },
|
|
equipment: { id: "equipment", group: "sheet", icon: "fas fa-hammer", label: "VERMINE.tabs.equipment" },
|
|
stories: { id: "stories", group: "sheet", icon: "fas fa-book-open-reader", label: "VERMINE.tabs.stories" },
|
|
combat: { id: "combat", group: "sheet", icon: "fas fa-medal", label: "VERMINE.tabs.combat" },
|
|
experience: { id: "experience", group: "sheet", icon: "fas fa-graduation-cap", label: "VERMINE.tabs.experience" }
|
|
}
|
|
for (const v of Object.values(tabs)) {
|
|
v.active = this.tabGroups[v.group] === v.id
|
|
v.cssClass = v.active ? "active" : ""
|
|
}
|
|
return tabs
|
|
}
|
|
|
|
async _prepareContext() {
|
|
const context = await super._prepareContext()
|
|
context.tabs = this.#getTabs()
|
|
return context
|
|
}
|
|
|
|
async _preparePartContext(partId, context) {
|
|
const doc = this.document
|
|
context.systemFields = doc.system.schema.fields
|
|
switch (partId) {
|
|
case "main": break
|
|
case "abilities":
|
|
context.tab = context.tabs.abilities
|
|
context.specialties = doc.itemTypes.specialty
|
|
break
|
|
case "totem":
|
|
context.tab = context.tabs.totem
|
|
context.abilities = doc.itemTypes.ability.filter(i => i.system.type !== "totem")
|
|
context.totem_abilities = doc.itemTypes.ability.filter(i => i.system.type === "totem")
|
|
context.specialties = doc.itemTypes.specialty
|
|
context.backgrounds = doc.itemTypes.background
|
|
context.traumas = doc.itemTypes.trauma
|
|
context.evolutions = doc.itemTypes.evolution
|
|
break
|
|
case "equipment":
|
|
context.tab = context.tabs.equipment
|
|
context.gear = doc.itemTypes.item
|
|
context.weapons = doc.itemTypes.weapon
|
|
context.defenses = doc.itemTypes.defense
|
|
context.vehicles = game.actors.filter(a => a.type === "vehicle" && a.system.ownerId === doc.id)
|
|
break
|
|
case "stories":
|
|
context.tab = context.tabs.stories
|
|
break
|
|
case "combat":
|
|
context.tab = context.tabs.combat
|
|
context.equippedWeapons = doc.itemTypes.weapon.filter(i => i.system.equipped)
|
|
context.equippedDefenses = doc.itemTypes.defense.filter(i => i.system.equipped)
|
|
const { prepareActiveEffectCategories } = await import("../../system/effects.mjs")
|
|
context.effects = prepareActiveEffectCategories(doc.effects)
|
|
break
|
|
case "experience":
|
|
context.tab = context.tabs.experience
|
|
context.specialtyCount = doc.itemTypes.specialty.length
|
|
const ex = doc.system.experience
|
|
context.experience = ex
|
|
context.collectiveTotal = (ex.collective.danger + ex.collective.discoveries + ex.collective.duration)
|
|
context.individualTotal = (ex.individual.implication + ex.individual.influence + ex.individual.interpretation)
|
|
context.currentPhase = ex.phase
|
|
context.learnedCurrent = ex.learned.phase === ex.phase
|
|
break
|
|
}
|
|
return context
|
|
}
|
|
|
|
changeTab(tab, group, options = {}) {
|
|
super.changeTab(tab, group, options)
|
|
if (group === "sheet") {
|
|
const main = this.element?.querySelector('[data-group="sheet"][data-tab="main"]')
|
|
if (main) main.classList.add("active")
|
|
}
|
|
}
|
|
|
|
static async #onAddSpecialty(event, target) {
|
|
const skillKey = target.dataset.skill
|
|
const name = game.i18n.localize("ITEMS.new_specialty")
|
|
const itemData = { name, type: "specialty" }
|
|
if (skillKey) itemData.system = { skill: skillKey }
|
|
await this.document.createEmbeddedDocuments("Item", [itemData])
|
|
}
|
|
|
|
static async #onOpenExperiencePhase(event, target) {
|
|
const { default: ExperiencePhaseDialog } = await import("../../system/dialogs/experiencePhaseDialog.mjs")
|
|
const dialog = await ExperiencePhaseDialog.create()
|
|
if (dialog) dialog.render(true)
|
|
}
|
|
|
|
static async #onOpenLearning(event, target) {
|
|
const { default: LearningDialog } = await import("../../system/dialogs/learningDialog.mjs")
|
|
const dialog = await LearningDialog.create({ actorId: this.document.id })
|
|
if (dialog) dialog.render(true)
|
|
}
|
|
}
|