removed code duplication of item body from talent

- added  isPhysical boolean to getData output of item-sheet.ts
- added isPhysical checks for displays of physical-only information
  in templates
This commit is contained in:
Gesina Schwalbe 2021-01-06 16:10:56 +01:00
parent 5bdfdd410b
commit e6b51c66a6
5 changed files with 32 additions and 51 deletions

View file

@ -39,6 +39,10 @@ interface DS4ItemPhysical {
storageLocation: string;
}
export function isDS4ItemDataTypePhysical(input: DS4ItemDataType): boolean {
return "quantity" in input && "price" in input && "availability" in input && "storageLocation" in input;
}
interface DS4ItemEquipable {
equipped: boolean;
}

View file

@ -1,5 +1,5 @@
import { DS4Item } from "./item";
import { DS4ItemDataType } from "./item-data";
import { DS4ItemDataType, isDS4ItemDataTypePhysical } from "./item-data";
/**
* Extend the basic ItemSheet with some very simple modifications
@ -26,7 +26,13 @@ export class DS4ItemSheet extends ItemSheet<DS4ItemDataType, DS4Item> {
/** @override */
getData(): ItemSheetData<DS4ItemDataType, DS4Item> {
const data = { ...super.getData(), config: CONFIG.DS4, isOwned: this.item.isOwned, actor: this.item.actor };
const data = {
...super.getData(),
config: CONFIG.DS4,
isOwned: this.item.isOwned,
actor: this.item.actor,
isPhysical: isDS4ItemDataTypePhysical(this.item.data.data),
};
console.log(data);
return data;
}