Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Haxxer committed Oct 20, 2023
1 parent b77ef83 commit f5a3470
Show file tree
Hide file tree
Showing 8 changed files with 257 additions and 226 deletions.
11 changes: 11 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Item Piles Changelog

## Version 2.7.18

- Added optional logging to merchants
- Added hook: `item-piles-preRefreshInventory`
- Called when the inventory of a merchant is refreshed by Simple Calendar, which will allow you to add additional changes to the merchant, or fully interrupt that merchant's refresh
- Updated Portuguese localization (thanks to ltsoares on weblate!)
- Updated Star Wars: Saga Edition system configuration (thanks to cpadilla on github!)
- Fixed secondary currencies would not be cached in the Item Piles currency compendium
- Fixed buying/selling things on merchants with secondary currencies
- Fixed adding currency to item piles & vaults not updating to the correct amount

## Version 2.7.17

- Fixed services would not stack and instead duplicate when added to merchants - if you still want non-stacking services, set them as non-stacking in the service's settings
Expand Down
5 changes: 1 addition & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Item Piles works in any system, but requires setup. If you wish to request nativ
Item Piles is designed to work in all systems, but may require some setup for it to fully function. Please refer to the module settings to configure that.

- [Dungeons & Dragons 5e](https://foundryvtt.com/packages/dnd5e)
- [Pathfinder 2e](https://foundryvtt.com/packages/pf2e)
- [Pathfinder 1e](https://foundryvtt.com/packages/pf1)
- [Dungeon Slayers 4](https://foundryvtt.com/packages/ds4)
- [D&D 3.5e SRD](https://foundryvtt.com/packages/D35E)
Expand Down Expand Up @@ -107,10 +108,6 @@ These systems have integrated their own support of Item Piles, rather than Item
- [Old-School Essentials](https://foundryvtt.com/packages/ose)
- [Cepheus & Traveller](https://foundryvtt.com/packages/twodsix)

## Semi-supported systems

- [Pathfinder 2e](https://foundryvtt.com/packages/pf2e) - Major features for Item Piles does not work in this system, such as dropping items on scenes to create item piles, and dropping items on tokens to give it to them. Merchants and existing piles still work, but the module is not strictly needed as PF2e already has a loot actor.

## Issues

Any issues, bugs, or feature requests are always welcome to be reported directly to the [Issue Tracker](https://github.com/fantasycalendar/FoundryVTT-ItemPiles/issues), or using the [Bug Reporter Module](https://foundryvtt.com/packages/bug-reporter/).
Expand Down
16 changes: 16 additions & 0 deletions docs/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
- [item-piles-preSplitItemPileContent](#item-piles-preSplitItemPileContent)
- [item-piles-splitItemPileContent](#item-piles-splitItemPileContent)
- [item-piles-preClickItemPile](#item-piles-preClickItemPile)
- [item-piles-preClickDirectoryItemPile](#item-piles-preClickDirectoryItemPile)
- [item-piles-preRightClickItem](#item-piles-preRightClickItem)
- [item-piles-preRefreshInventory](#item-piles-preRefreshInventory)

- [Items](#Items)
- [item-piles-preDropItemDetermined](#item-piles-preDropItemDetermined)
Expand Down Expand Up @@ -513,6 +516,19 @@ If the hook returns `false`, the action is interrupted.

---

### item-piles-preRefreshInventory

Called before a merchant has had their inventory refreshed by item piles

| Param | Type | Description |
|---------|---------------------|------------------------------------------------------------------------------------------|
| actor | <code>Actor</code> | The merchant actor that is going to have its inventory refreshed |
| changes | <code>Object</code> | The object containing all of the information that is going to be altered on the merchant |

If the hook returns `false`, the action is interrupted.

---

## Items

### item-piles-preDropItemDetermined
Expand Down
3 changes: 2 additions & 1 deletion src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ CONSTANTS.HOOKS = {
SPLIT_INVENTORY: module`splitItemPileContent`,
PRE_CLICK: module`preClickItemPile`,
PRE_DIRECTORY_CLICK: module`preClickDirectoryItemPile`,
PRE_RIGHT_CLICK_ITEM: module`preRightClickItem`
PRE_RIGHT_CLICK_ITEM: module`preRightClickItem`,
PRE_REFRESH_INVENTORY: module`preRefreshInventory`
},
ITEM: {
PRE_DROP_DETERMINED: module`preDropItemDetermined`,
Expand Down
3 changes: 1 addition & 2 deletions src/helpers/compendium-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ export async function findSimilarItemInCompendium(itemToFind) {
const pack = await getItemCompendium();
const item = game.packs.get(PACK_ID).index.find(compendiumItem => {
return compendiumItem.name === itemToFind.name
&& compendiumItem.type === itemToFind.type
&& compendiumItem.img === itemToFind.img;
&& compendiumItem.type === itemToFind.type;
});
return (item?._id ? pack.getDocument(item._id) : false);
}
Expand Down
4 changes: 3 additions & 1 deletion src/helpers/pile-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,9 @@ export function getMerchantModifiersForActor(merchant, {
}

function getSmallestExchangeRate(currencies) {
return currencies.length > 1 ? Math.min(...currencies.map(currency => currency.exchangeRate)) : (Helpers.getSetting(SETTINGS.CURRENCY_DECIMAL_DIGITS) ?? 0.00001);
return currencies.length > 1
? Math.min(...currencies.filter(currency => currency.primary).map(currency => currency.exchangeRate))
: (Helpers.getSetting(SETTINGS.CURRENCY_DECIMAL_DIGITS) ?? 0.00001);
}

function getExchangeRateDecimals(smallestExchangeRate) {
Expand Down
Loading

0 comments on commit f5a3470

Please sign in to comment.