Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Haxxer committed Aug 30, 2024
1 parent a44b3f8 commit c735d90
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Item Piles Changelog

## Version 3.1.2

- Fixed custom purchase and sell prices not working properly
- Fixed some more localization in the item editor application
- Fixed dragging and dropping items onto existing item piles not working
- Fixed item pile settings on items not being saved properly

## Version 3.1.1

- Updated PF1e system support (thank you Mana!)
Expand Down
3 changes: 2 additions & 1 deletion src/API/private-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ export default class PrivateAPI {
const sourceTransaction = new Transaction(sourceActor);
if (SYSTEMS.DATA.ITEM_TYPE_HANDLERS) {
const newItems = [];
for (const itemData of items) {
for (const data of items) {
const itemData = data?.item ?? data;
const item = sourceActor.items.get(itemData._id ?? itemData.id);
const handler = Utilities.getItemTypeHandler(CONSTANTS.ITEM_TYPE_METHODS.TRANSFER, item.type);
if (!handler) continue;
Expand Down
7 changes: 4 additions & 3 deletions src/applications/components/PriceList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,16 @@
<div class="item-piles-sortable-list-columns" style="margin-top: 0.5rem;">
<div class="full-span">
<a class:invisible={isHovering} on:click={() => addAttribute()}>
{localize("ITEM-PILES.Applications.ItemEditor.DropMeClickMe")}
{localize("ITEM-PILES.Applications.ItemEditor.PriceTab.DropMeClickMe")}
</a>
</div>
{#if presetPrices.length && presets}
<div class="full-span" style="margin-top:0.5rem;">
<span style="margin-right:0.25rem;">{localize("ITEM-PILES.Applications.ItemEditor.PricePreset")}</span>
<span
style="margin-right:0.25rem;">{localize("ITEM-PILES.Applications.ItemEditor.PriceTab.PricePreset")}</span>
<select class="price-preset-selector" bind:value={selectedPreset}
on:change={() => { addPreset(selectedPreset); selectedPreset = ""; }}>
<option value="">{localize("ITEM-PILES.Applications.ItemEditor.SelectPreset")}</option>
<option value="">{localize("ITEM-PILES.Applications.ItemEditor.PriceTab.SelectPreset")}</option>
{#each presetPrices as price, index (index)}
<option value={index}>{localize(price.name)}</option>
{/each}
Expand Down
17 changes: 3 additions & 14 deletions src/applications/merchant-app/components/ItemEntry.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,20 @@
const store = item.store;
const pileData = store.pileData;
const displayQuantityStore = item.displayQuantity;
const infiniteQuantityStore = item.infiniteQuantity;
const quantityStore = item.quantity;
const itemFlagDataStore = item.itemFlagData;
$: itemFlagData = $itemFlagDataStore;
$: displayQuantity = $displayQuantityStore;
$: infiniteQuantity = $infiniteQuantityStore;
$: quantity = $quantityStore;
$: editQuantity = $quantityStore;
$: itemName = $itemNameStore + ($itemQuantityForPrice > 1 ? ` (${$itemQuantityForPrice})` : "");
const displayControlButtons = store.actor.isOwner;
const displayBuyButton = !!store.recipient;
</script>

<div class="item-piles-merchant-item-container"
class:merchant-item-hidden={itemFlagData.hidden}>
class:merchant-item-hidden={$itemFlagDataStore.hidden}>

<div
class="item-piles-img-container"
class:not-for-sale={itemFlagData.notForSale || !quantity}
data-fast-tooltip={itemFlagData.notForSale ? "Not for sale" : ""}
class:not-for-sale={$itemFlagDataStore.notForSale || !$quantityStore}
data-fast-tooltip={$itemFlagDataStore.notForSale ? "Not for sale" : ""}
>
<img class="item-piles-img" src={$itemImage}/>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/pile-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ export function cleanItemFlagData(flagData, { addRemoveFlag = false } = {}) {
}

export function updateItemData(item, update, { returnUpdate = false, version = false } = {}) {
const flagData = cleanItemFlagData(foundry.utils.mergeObject(getItemFlagData(item), update.flags ?? {}));
const flagData = cleanItemFlagData(foundry.utils.mergeObject(getItemFlagData(item), update.flags ?? {}), { addRemoveFlag: true });
const updates = foundry.utils.mergeObject(update?.data ?? {}, {});
foundry.utils.setProperty(updates, CONSTANTS.FLAGS.ITEM, flagData)
foundry.utils.setProperty(updates, CONSTANTS.FLAGS.VERSION, version || Helpers.getModuleVersion())
Expand Down Expand Up @@ -1247,7 +1247,7 @@ export function getPriceData({

}

const disableNormalCost = itemFlagData.disableNormalCost && !sellerFlagData.onlyAcceptBasePrice;
const disableNormalCost = itemFlagData.disableNormalCost && (merchant === seller || !sellerFlagData.onlyAcceptBasePrice);
const hasOtherPrices = secondaryPrices?.length > 0 || itemFlagData.prices.filter(priceGroup => priceGroup.length).length > 0 || itemFlagData.sellPrices.filter(priceGroup => priceGroup.length).length > 0;

const currencyList = getCurrencyList(merchant);
Expand Down Expand Up @@ -1367,7 +1367,7 @@ export function getPriceData({

}

if (itemFlagData.prices.length && ((merchant === seller && !sellerFlagData.onlyAcceptBasePrice) || (merchant === buyer && itemFlagData.purchaseOptionsAsSellOption && !buyerFlagData.onlyAcceptBasePrice))) {
if (itemFlagData.prices.length && (merchant === seller || (itemFlagData.purchaseOptionsAsSellOption && !buyerFlagData.onlyAcceptBasePrice))) {
priceData = priceData.concat(getItemFlagPriceData(itemFlagData.prices, quantity, modifier, defaultCurrencies, currencyList));
}

Expand Down

0 comments on commit c735d90

Please sign in to comment.