import { OseActor } from "./entity.js"; import { OseActorSheet } from "./actor-sheet.js"; /** * Extend the basic ActorSheet with some very simple modifications */ export class OseActorSheetCharacter extends OseActorSheet { constructor(...args) { super(...args); } /* -------------------------------------------- */ /** * Extend and override the default options used by the 5e Actor Sheet * @returns {Object} */ static get defaultOptions() { return mergeObject(super.defaultOptions, { classes: ["ose", "sheet", "actor", "character"], template: "systems/ose/templates/actors/character-sheet.html", width: 450, height: 560, resizable: true, tabs: [ { navSelector: ".tabs", contentSelector: ".sheet-body", initial: "attributes", }, ], }); } /** * Prepare data for rendering the Actor sheet * The prepared data object contains both the actor data as well as additional sheet options */ getData() { const data = super.getData(); data.config = CONFIG.OSE; for (let [a, score] of Object.entries(data.data.scores)) { data.data.scores[a].label = game.i18n.localize(`OSE.scores.${a}`); } // Prepare owned items this._prepareItems(data); // Settings data.config.individualInit = game.settings.get('ose', 'individualInit'); return data; } /** * Organize and classify Owned Items for Character sheets * @private */ _prepareItems(data) { // Partition items by category let [inventory, abilities, spells] = data.items.reduce( (arr, item) => { // Classify items into types if (item.type === "item") arr[0].push(item); if (item.type === "ability") arr[1].push(item); else if (item.type === "spell") arr[2].push(item); return arr; }, [[], [], [], []] ); // Assign and return data.inventory = inventory; data.spells = spells; data.abilities = abilities; } /* -------------------------------------------- */ _onItemSummary(event) { event.preventDefault(); let li = $(event.currentTarget).parents(".item"), item = this.actor.getOwnedItem(li.data("item-id")), description = TextEditor.enrichHTML(item.data.data.description); // Toggle summary if ( li.hasClass("expanded") ) { let summary = li.parents('.item-entry').children(".item-summary"); summary.slideUp(200, () => summary.remove()); } else { let div = $(`