From db7ec3ce34863dbd2dd084df28dc652c35193a00 Mon Sep 17 00:00:00 2001 From: Haxxer Date: Mon, 2 Sep 2024 11:45:09 +0100 Subject: [PATCH] Changelog --- changelog.md | 1 + src/helpers/utilities.js | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/changelog.md b/changelog.md index 641df983..1e2034a9 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ ## Version 3.1.3 - Updated Polish localization (thank you Lioheart on weblate!) +- Fixed some issues with Custom System Builder and item pile item quantities - Fixed issues with merchants and custom prices utilizing secondary currencies - Fixed adding container and non-stackable items into item piles from the same source would throw Foundry database errors - Fixed merchant populate items tab not loading if a table had been added to the merchant and subsequently deleted diff --git a/src/helpers/utilities.js b/src/helpers/utilities.js index 877af9be..0566b889 100644 --- a/src/helpers/utilities.js +++ b/src/helpers/utilities.js @@ -150,19 +150,20 @@ export function getDocumentTemplates(templateType) { * @returns {Set} The items type that can be stacked on this system */ export function getItemTypesThatCanStack() { - if (!itemTypesWithQuantities) { - itemTypesWithQuantities = new Set(); + itemTypesWithQuantities ??= new Set(); - if (game.system.id === "custom-system-builder") { - const quantityAttribute = game.itempiles.API.ITEM_QUANTITY_ATTRIBUTE.split(".").pop(); - const itemTemplates = game.items - .filter(_i => _i?.templateSystem?.isTemplate && _i?.templateSystem?.getKeys) - .filter(_i => _i.templateSystem.getKeys().has(quantityAttribute)); - for (const item of itemTemplates) { - itemTypesWithQuantities.add(item.name); - } + if (game.system.id === "custom-system-builder") { + const quantityAttribute = game.itempiles.API.ITEM_QUANTITY_ATTRIBUTE.split(".").pop(); + const itemTemplates = game.items + .filter(_i => _i?.templateSystem?.isTemplate && _i?.templateSystem?.getKeys) + .filter(_i => _i.templateSystem.getKeys().has(quantityAttribute)); + for (const item of itemTemplates) { + itemTypesWithQuantities.add(item.name); } + } + + if (!itemTypesWithQuantities) { const unstackableItemTypes = Helpers.getSetting(SETTINGS.UNSTACKABLE_ITEM_TYPES); const templates = getDocumentTemplates("Item"); @@ -180,6 +181,7 @@ export function getItemTypesThatCanStack() { return hasItemQuantity(itemTemplate); })].filter(type => !unstackableItemTypes.includes(type))); } + return itemTypesWithQuantities; }