Files
vermine2047/module/sheets/item-sheet.mjs
T
uberwald 30d6f71fc7 fix: Correct critical bugs and complete Creature/Group DataModel implementation
- Fix TypeError: controls.find is not a function in hooks.mjs
- Fix undefined 'npc' variable in applications.mjs
- Fix CONFIG.VERMINE.model undefined by checking game.system.template existence
- Fix TypeError: html.find(...).forEach is not a function in roll.mjs
- Fix Cannot set properties of undefined (setting 'initial') in actor.mjs
- Fix Cannot read properties of undefined (reading 'difficulty') in actor.mjs
- Fix ActiveEffect application phase 'initial' already completed by adding combatStatus to base template
- Fix Missing helper: 'select' in roll-dialog.hbs (removed invalid Handlebars select block)
- Add SIZE_LEVELS labels to creatureSizeLevels config
- Add SIZE_LEVELS translations to fr.json
- Add combatStatus to base actor template
- Convert all .html templates to .hbs for Foundry v14 compatibility
- Update item-sheet.mjs to use .hbs extension
- Update handlebars-manager.mjs to use .hbs for all partials

Complete Vermine2047 Creature and Group sheet implementation:
- Creature: Pattern, Size, Role, Pack with computed values
- Group: Totem, Reserve, Morale, Objectives, Members management
- All templates functional with proper styling

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-06-04 22:22:52 +02:00

81 lines
2.1 KiB
JavaScript

import { TraitSelector } from "../system/applications.mjs";
/**
* Extend the basic ItemSheet with some very simple modifications
* @extends {ItemSheet}
*/
export class VermineItemSheet extends ItemSheet {
/** @override */
static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["vermine2047", "sheet", "item"],
width: 450,
height: "max-content",
tabs: [{ navSelector: ".sheet-tabs", contentSelector: ".sheet-body", initial: "description" }]
});
}
/** @override */
get template() {
const path = "systems/vermine2047/templates/item";
return `${path}/item-${this.item.type}-sheet.hbs`;
}
/* -------------------------------------------- */
/** @override */
getData() {
// Retrieve base data structure.
const context = super.getData();
// Use a safe clone of the item data for further operations.
const itemData = context.item;
// Retrieve the roll data for TinyMCE editors.
context.rollData = {};
let actor = this.object?.parent ?? null;
if (actor) {
context.rollData = actor.getRollData();
}
// Add the actor's data to context.data for easier access, as well as flags.
context.system = itemData.system;
context.flags = itemData.flags;
context.config = CONFIG.VERMINE;
return context;
}
/* -------------------------------------------- */
/** @override */
activateListeners(html) {
super.activateListeners(html);
// Everything below here is only needed if the sheet is editable
if (!this.isEditable) return;
//click on wound radio
html.find('.damages-row [type="radio"]').click(ev => {
this._onClickDamage(ev)
})
html.find('.traits-selector').click(ev => {
this.openTraitSelector(ev)
})
}
async _onClickDamage(ev) {
if (!ev.currentTarget.checked) { return }
let prop = ev.currentTarget.name;
let update = {};
update[prop] = ev.currentTarget.value - 1
this.item.update(update)
}
async openTraitSelector(ev) {
let selector = new TraitSelector(this.item);
selector.render(true)
}
}