mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
* FEAT: create isNPC geeter and add the prop on metada on actors FEAT: create common method for documents sheets FEAT: create BaseActorSheet and implementation * FIX: tabs label * REFACTOR: remove unused methods REFACTOR: simplify CharacterSheet's click actions methods REFACTOR: minor fix on DHActor class * REFACTOR: remove unused methods REFACTOR: create method on BaseActorSheet REFACTOR: make Datamodel metadata getter * REFACTOR: remove unused method on setting sheet FEAT: create BaseActorSetting FIX: add type="button" to button on actor's sheet * FIX jsdoc * PRETTIER --------- Co-authored-by: Joaquin Pereyra <joaquinpereyra98@users.noreply.github.com>
80 lines
2.8 KiB
JavaScript
80 lines
2.8 KiB
JavaScript
import DHBaseActorSheet from '../api/base-actor.mjs';
|
|
|
|
/**@typedef {import('@client/applications/_types.mjs').ApplicationClickAction} ApplicationClickAction */
|
|
|
|
export default class DhCompanionSheet extends DHBaseActorSheet {
|
|
static DEFAULT_OPTIONS = {
|
|
classes: ['actor', 'companion'],
|
|
position: { width: 300 },
|
|
actions: {
|
|
viewActor: this.viewActor,
|
|
useItem: this.useItem,
|
|
toChat: this.toChat
|
|
}
|
|
};
|
|
|
|
static PARTS = {
|
|
header: { template: 'systems/daggerheart/templates/sheets/actors/companion/header.hbs' },
|
|
details: { template: 'systems/daggerheart/templates/sheets/actors/companion/details.hbs' },
|
|
effects: { template: 'systems/daggerheart/templates/sheets/actors/companion/effects.hbs' }
|
|
};
|
|
|
|
/* -------------------------------------------- */
|
|
|
|
/** @inheritdoc */
|
|
static TABS = {
|
|
primary: {
|
|
tabs: [{ id: 'details' }, { id: 'effects' }],
|
|
initial: 'details',
|
|
labelPrefix: 'DAGGERHEART.GENERAL.Tabs'
|
|
}
|
|
};
|
|
|
|
/* -------------------------------------------- */
|
|
/* Application Clicks Actions */
|
|
/* -------------------------------------------- */
|
|
|
|
static async viewActor(_, button) {
|
|
const target = button.closest('[data-item-uuid]');
|
|
const actor = await foundry.utils.fromUuid(target.dataset.itemUuid);
|
|
if (!actor) return;
|
|
|
|
actor.sheet.render(true);
|
|
}
|
|
|
|
getAction(element) {
|
|
const itemId = (element.target ?? element).closest('[data-item-id]').dataset.itemId,
|
|
item = this.document.system.actions.find(x => x.id === itemId);
|
|
return item;
|
|
}
|
|
|
|
static async useItem(event) {
|
|
const action = this.getAction(event) ?? this.actor.system.attack;
|
|
action.use(event);
|
|
}
|
|
|
|
static async toChat(event, button) {
|
|
if (button?.dataset?.type === 'experience') {
|
|
const experience = this.document.system.experiences[button.dataset.uuid];
|
|
const cls = getDocumentClass('ChatMessage');
|
|
const systemData = {
|
|
name: game.i18n.localize('DAGGERHEART.GENERAL.Experience.single'),
|
|
description: `${experience.name} ${experience.total < 0 ? experience.total : `+${experience.total}`}`
|
|
};
|
|
const msg = new cls({
|
|
type: 'abilityUse',
|
|
user: game.user.id,
|
|
system: systemData,
|
|
content: await foundry.applications.handlebars.renderTemplate(
|
|
'systems/daggerheart/templates/ui/chat/ability-use.hbs',
|
|
systemData
|
|
)
|
|
});
|
|
|
|
cls.create(msg.toObject());
|
|
} else {
|
|
const item = this.getAction(event) ?? this.document.system.attack;
|
|
item.toChat(this.document.id);
|
|
}
|
|
}
|
|
}
|