diff --git a/src/module/item/item-data.ts b/src/module/item/item-data.ts index be1a0042..3af52fd2 100644 --- a/src/module/item/item-data.ts +++ b/src/module/item/item-data.ts @@ -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; } diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index ac8197aa..8670dc3e 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -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 { /** @override */ getData(): ItemSheetData { - 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; } diff --git a/src/templates/item/partials/body.hbs b/src/templates/item/partials/body.hbs index 9770815b..1f465d9f 100644 --- a/src/templates/item/partials/body.hbs +++ b/src/templates/item/partials/body.hbs @@ -4,7 +4,9 @@ {{!-- Sheet Body --}} @@ -13,10 +15,12 @@ {{!-- Description Tab --}} {{> systems/ds4/templates/item/partials/description.hbs}} - {{!-- Details Tab --}} - {{> systems/ds4/templates/item/partials/details.hbs}} - {{!-- Effects Tab --}} {{> systems/ds4/templates/item/partials/effects.hbs}} + {{#if isPhysical}} + {{!-- Details Tab --}} + {{> systems/ds4/templates/item/partials/details.hbs}} + {{/if}} + \ No newline at end of file diff --git a/src/templates/item/partials/description.hbs b/src/templates/item/partials/description.hbs index db3253bc..d7088a30 100644 --- a/src/templates/item/partials/description.hbs +++ b/src/templates/item/partials/description.hbs @@ -11,14 +11,16 @@ {{actor.name}} -
- - -
-
- - -
+ {{#if isPhysical}} +
+ + +
+
+ + +
+ {{/if}} {{else}} {{localize "DS4.NotOwned"}} {{/if}} diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs index 69c24137..a4be9b03 100644 --- a/src/templates/item/talent-sheet.hbs +++ b/src/templates/item/talent-sheet.hbs @@ -30,43 +30,8 @@ - - {{!-- Sheet Tab Navigation --}} - - - {{!-- Sheet Body --}} -
- {{!-- The item tab for details. --}} -
- {{!-- As you add new fields, add them in here! --}} -
- {{!-- TODO: remove duplication of isOwned section here and in description.hbs--}} - {{#if isOwned}} - {{#if (ne data.equipped undefined)}}
- - -
- {{/if}} -
- - {{actor.name}} -
- {{else}} - {{localize "DS4.NotOwned"}} - {{/if}} -
-
- {{editor content=data.description target="data.description" button=true owner=owner editable=editable}} -
-
- - {{!-- Effects Tab --}} - {{> systems/ds4/templates/item/partials/effects.hbs }} - -
+ + {{!-- Common Item body --}} + {{> systems/ds4/templates/item/partials/body.hbs}}