Do some cleanup
This commit is contained in:
parent
98568de676
commit
d5db788c31
14 changed files with 91 additions and 109 deletions
|
@ -3,6 +3,9 @@ import { DS4Item } from "../item/item";
|
|||
import { ItemType } from "../item/item-data";
|
||||
import { DS4ActorData } from "./actor-data";
|
||||
|
||||
/**
|
||||
* The Actor class for DS4
|
||||
*/
|
||||
export class DS4Actor extends Actor<DS4ActorData, DS4Item> {
|
||||
/** @override */
|
||||
prepareDerivedData(): void {
|
||||
|
@ -45,7 +48,7 @@ export class DS4Actor extends Actor<DS4ActorData, DS4Item> {
|
|||
|
||||
/**
|
||||
* Checks whether or not the given item type can be owned by the actor.
|
||||
* @param itemType the item type to check
|
||||
* @param itemType - The item type to check
|
||||
*/
|
||||
canOwnItemType(itemType: ItemType): boolean {
|
||||
return this.ownableItemTypes.includes(itemType);
|
||||
|
|
|
@ -4,7 +4,7 @@ import { DS4ItemData } from "../../item/item-data";
|
|||
import { DS4Actor } from "../actor";
|
||||
|
||||
/**
|
||||
* Extend the basic ActorSheet with some very simple modifications
|
||||
* The base Sheet class for all DS4 Actors
|
||||
*/
|
||||
// TODO(types): Remove first generic parameter once https://github.com/League-of-Foundry-Developers/foundry-vtt-types/pull/273 is merged
|
||||
export class DS4ActorSheet extends ActorSheet<unknown, DS4Actor> {
|
||||
|
@ -43,13 +43,11 @@ export class DS4ActorSheet extends ActorSheet<unknown, DS4Actor> {
|
|||
return `${path}/${this.actor.data.type}-sheet.hbs`;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* This method returns the data for the template of the actor sheet.
|
||||
* It explicitly adds the items of the object sorted by type in the
|
||||
* object itemsByType.
|
||||
* @returns the data fed to the template of the actor sheet
|
||||
* @returns The data fed to the template of the actor sheet
|
||||
*/
|
||||
getData(): ActorSheet.Data<DS4Actor> {
|
||||
const data = {
|
||||
|
@ -62,8 +60,6 @@ export class DS4ActorSheet extends ActorSheet<unknown, DS4Actor> {
|
|||
return data;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @override */
|
||||
activateListeners(html: JQuery): void {
|
||||
super.activateListeners(html);
|
||||
|
@ -94,14 +90,11 @@ export class DS4ActorSheet extends ActorSheet<unknown, DS4Actor> {
|
|||
html.find(".rollable").click(this._onRoll.bind(this));
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Handle creating a new Owned Item for the actor using initial data defined in the HTML dataset
|
||||
* @param event The originating click event
|
||||
* @private
|
||||
* @param event - The originating click event
|
||||
*/
|
||||
private _onItemCreate(event: JQuery.ClickEvent): Promise<DS4ItemData> {
|
||||
protected _onItemCreate(event: JQuery.ClickEvent): Promise<DS4ItemData> {
|
||||
event.preventDefault();
|
||||
const header = event.currentTarget;
|
||||
// Get the type of item to create.
|
||||
|
@ -124,10 +117,9 @@ export class DS4ActorSheet extends ActorSheet<unknown, DS4Actor> {
|
|||
* Handle changes to properties of an Owned Item from within character sheet.
|
||||
* Can currently properly bind: see getValue().
|
||||
* Assumes the item property is given as the value of the HTML element property 'data-property'.
|
||||
* @param ev The originating change event
|
||||
* @private
|
||||
* @param ev - The originating change event
|
||||
*/
|
||||
private _onItemChange(ev: JQuery.ChangeEvent): void {
|
||||
protected _onItemChange(ev: JQuery.ChangeEvent): void {
|
||||
ev.preventDefault();
|
||||
console.log("Current target:", $(ev.currentTarget).get(0)["name"]);
|
||||
const el: HTMLFormElement = $(ev.currentTarget).get(0);
|
||||
|
@ -155,7 +147,7 @@ export class DS4ActorSheet extends ActorSheet<unknown, DS4Actor> {
|
|||
* - Checkbox: boolean
|
||||
* - Text input: string
|
||||
* - Number: number
|
||||
* @param el the input element to collect the value of
|
||||
* @param el - The input element to collect the value of
|
||||
*/
|
||||
private getValue(el: HTMLFormElement): boolean | string | number {
|
||||
// One needs to differentiate between e.g. checkboxes (value="on") and select boxes etc.
|
||||
|
@ -206,10 +198,9 @@ export class DS4ActorSheet extends ActorSheet<unknown, DS4Actor> {
|
|||
|
||||
/**
|
||||
* Handle clickable rolls.
|
||||
* @param event The originating click event
|
||||
* @private
|
||||
* @param event - The originating click event
|
||||
*/
|
||||
private _onRoll(event: JQuery.ClickEvent): void {
|
||||
protected _onRoll(event: JQuery.ClickEvent): void {
|
||||
event.preventDefault();
|
||||
const element = event.currentTarget;
|
||||
const dataset = element.dataset;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import { DS4ActorSheet } from "./actor-sheet";
|
||||
|
||||
/**
|
||||
* The Sheet class for DS4 Character Actors
|
||||
*/
|
||||
export class DS4CharacterActorSheet extends DS4ActorSheet {
|
||||
/** @override */
|
||||
static get defaultOptions(): BaseEntitySheet.Options {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import { DS4ActorSheet } from "./actor-sheet";
|
||||
|
||||
/**
|
||||
* The Sheet class for DS4 Creature Actors
|
||||
*/
|
||||
export class DS4CreatureActorSheet extends DS4ActorSheet {
|
||||
/** @override */
|
||||
static get defaultOptions(): BaseEntitySheet.Options {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue