Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Haxxer committed Aug 20, 2022
1 parent a6f4143 commit cafeb13
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
23 changes: 13 additions & 10 deletions src/API/private-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,11 @@ export default class PrivateAPI {
if (targetUuid) {
itemsDropped = await this._transferItems(sourceUuid, targetUuid, itemsToTransfer, userId);
} else {
itemsDropped = await this._removeItems(sourceUuid, itemsToTransfer, userId);
itemsDropped = (await this._removeItems(sourceUuid, itemsToTransfer, userId)).map(item => {
item.quantity = Math.abs(item.quantity)
setProperty(item.item, game.itempiles.ITEM_QUANTITY_ATTRIBUTE, Math.abs(item.quantity))
return item;
});
targetUuid = await this._createItemPile(sceneId, position, { items: itemsDropped });
}

Expand Down Expand Up @@ -553,7 +557,7 @@ export default class PrivateAPI {

if (!pileActorName) {

pileActor = Helpers.getSetting(SETTINGS.DEFAULT_ITEM_PILE_ACTOR_ID);
pileActor = game.actors.get(Helpers.getSetting(SETTINGS.DEFAULT_ITEM_PILE_ACTOR_ID));

if (!pileActor) {

Expand Down Expand Up @@ -614,8 +618,7 @@ export default class PrivateAPI {
}

items = items ? items.map(item => {
let itemData = item.item ?? item;
return itemData;
return item.item ?? item;
}) : [];

overrideData['actorData'] = {
Expand Down Expand Up @@ -1062,26 +1065,26 @@ export default class PrivateAPI {
}
}

if (droppableDocuments.length) {
action = "addToPile";
}

if (hotkeyState.altDown) {

if (droppableDocuments.length) {
action = "addToPile";
}

setProperty(dropData.itemData.item, game.itempiles.ITEM_QUANTITY_ATTRIBUTE, 1);
dropData.itemData.quantity = 1;

} else {

const quantity = getProperty(dropData.itemData.item, game.itempiles.ITEM_QUANTITY_ATTRIBUTE);
const quantity = Utilities.getItemQuantity(dropData.itemData.item);

let result = { action: "addToPile", quantity: 1 }
if (quantity > 1) {
result = await DropItemDialog.show(item, droppableDocuments[0]);
if (!result) return false;
action = result.action;
}

action = result.action;
setProperty(dropData.itemData.item, game.itempiles.ITEM_QUANTITY_ATTRIBUTE, Number(result.quantity))
dropData.itemData.quantity = Number(result.quantity);

Expand Down
6 changes: 4 additions & 2 deletions src/applications/item-pile-inventory-app/ListEntry.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
export let store;
export let entry;
const name = entry.name;
const img = entry.img;
const quantityLeft = entry.quantityLeft;
const quantity = entry.quantity;
const currentQuantity = entry.currentQuantity;
Expand Down Expand Up @@ -38,12 +40,12 @@
on:mouseenter={mouseEnterImage}
on:mouseleave={mouseLeaveImage}
/>-->
<img class="item-piles-img" src="{entry.img}"/>
<img class="item-piles-img" src="{$img}"/>
</div>

<div class="item-piles-name">
<div class="item-piles-name-container">
<p class:item-piles-clickable-link="{canPreview}" on:click={previewItem}>{entry.name}</p>
<p class:item-piles-clickable-link="{canPreview}" on:click={previewItem}>{$name}</p>
{#if !editQuantities}
<span class="item-piles-small-text">(x{$quantity})</span>
{/if}
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class Transaction {
for (let data of items) {
let item = data.item ?? data;
let itemData = item instanceof Item ? item.toObject() : item;
if (SYSTEMS.DATA.ITEM_TRANSFORMER) {
if (SYSTEMS.DATA.ITEM_TRANSFORMER && !remove) {
itemData = await SYSTEMS.DATA.ITEM_TRANSFORMER(itemData);
}
const incomingQuantity = Math.abs(data.quantity ?? Utilities.getItemQuantity(itemData)) * (remove ? -1 : 1);
Expand Down

0 comments on commit cafeb13

Please sign in to comment.