From cbd5af8d02e3b6bef5ad84bb1aa99ce575b065cc Mon Sep 17 00:00:00 2001 From: Vlyan Date: Sun, 17 Jan 2021 17:47:42 +0100 Subject: [PATCH] Added a visual indicator for equipped / readied Now only equipped armor / weapon will show in conflict tab, and all armors/weapons now show in inventory tab --- CHANGELOG.md | 3 ++ system/scripts/actors/base-sheet.js | 35 +++++++++++++++++++ system/templates/items/armor/armors.html | 2 +- system/templates/items/item/item-entry.html | 7 ++-- system/templates/items/item/items.html | 2 +- .../templates/items/weapon/weapon-entry.html | 5 ++- system/templates/items/weapon/weapons.html | 2 +- 7 files changed, 49 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cacfb61..af90e23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ - Added a GM Dialog Tool for setting global difficulty (TN) value / hidden (with DicePicker live refresh) - Compendium now display Ring and Rank if any in list view - DicePicker : Fixed the initial display of "use a void point" +- PC/NPC Sheet : + - Added a visual indicator for equipped / readied + - Now only equipped armor / weapon will show in conflict tab, and all armors/weapons now show in inventory tab ## 1.0.0 - First public release - Removed the 0ds if no skill point diff --git a/system/scripts/actors/base-sheet.js b/system/scripts/actors/base-sheet.js index 5221e91..8e28108 100644 --- a/system/scripts/actors/base-sheet.js +++ b/system/scripts/actors/base-sheet.js @@ -197,6 +197,13 @@ export class BaseSheetL5r5e extends ActorSheet { } }); + // Equipped / Readied + html.find(".equip-readied-control").on("click", (event) => { + event.preventDefault(); + event.stopPropagation(); + this._switchEquipReadied(event); + }); + // *** Items : add, edit, delete *** html.find(".item-add").on("click", (event) => { event.preventDefault(); @@ -339,4 +346,32 @@ export class BaseSheetL5r5e extends ActorSheet { } return false; } + + /** + * Switch Readied state on a weapon + * @private + */ + _switchEquipReadied(event) { + const type = $(event.currentTarget).data("type"); + if (!["equipped", "readied"].includes(type)) { + return; + } + + const itemId = $(event.currentTarget).data("item-id"); + const tmpItem = this.actor.getOwnedItem(itemId); + if (!tmpItem || tmpItem.data.data[type] === undefined) { + return; + } + + tmpItem.data.data[type] = !tmpItem.data.data[type]; + const data = { + equipped: tmpItem.data.data.equipped, + }; + // Only weapons + if (tmpItem.data.data.readied !== undefined) { + data.readied = tmpItem.data.data.readied; + } + + tmpItem.update({ data }); + } } diff --git a/system/templates/items/armor/armors.html b/system/templates/items/armor/armors.html index 69611d9..ceaba3b 100644 --- a/system/templates/items/armor/armors.html +++ b/system/templates/items/armor/armors.html @@ -7,7 +7,7 @@ {{#if item.data.description}} -
{{{ item.data.description }}}
+
{{{ item.data.description }}}
{{/if}} \ No newline at end of file diff --git a/system/templates/items/item/items.html b/system/templates/items/item/items.html index a2dbfa5..395bbb2 100644 --- a/system/templates/items/item/items.html +++ b/system/templates/items/item/items.html @@ -7,7 +7,7 @@ {{#if item.data.description}} -
{{{ item.data.description }}}
+
{{{ item.data.description }}}
{{/if}} \ No newline at end of file diff --git a/system/templates/items/weapon/weapons.html b/system/templates/items/weapon/weapons.html index 2af0ab3..08b80c5 100644 --- a/system/templates/items/weapon/weapons.html +++ b/system/templates/items/weapon/weapons.html @@ -7,7 +7,7 @@