Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Haxxer committed Jan 17, 2024
1 parent 2880265 commit bcb78ac
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/API/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1215,9 +1215,9 @@ class API {
} else if (itemData.item) {
item = itemData.item instanceof Item ? itemData.item.toObject() : itemData.item;
if (itemData.flags) {
foundry.utils.setProperty(item, "flags", foundry.utils.mergeObject(
foundry.utils.getProperty(item, "flags") ?? {},
foundry.utils.getProperty(itemData, "flags"))
foundry.utils.setProperty(item, CONSTANTS.FLAGS.ITEM, foundry.utils.mergeObject(
foundry.utils.getProperty(item, CONSTANTS.FLAGS.ITEM) ?? {},
foundry.utils.getProperty(itemData, CONSTANTS.FLAGS.ITEM))
);
}
} else if (itemData.id) {
Expand Down Expand Up @@ -1352,7 +1352,7 @@ class API {
return {
id: item._id,
quantity: Math.max(itemData?.quantity ?? Utilities.getItemQuantity(itemData), 0),
flags: foundry.utils.getProperty(itemData, "flags")
flags: foundry.utils.getProperty(itemData, CONSTANTS.FLAGS.ITEM)
}
});

Expand Down Expand Up @@ -1700,7 +1700,7 @@ class API {
*
* @param {Array<object>} currencies An array of object containing the data and quantity for each currency
| * @param {number} currencies[].cost The cost of the currency
| * @param {string} currencies[].denom The abbreviation of the currency, which are usually {#}GP, which when {#} is replaced with the number it becomes 5GP.
| * @param {string} currencies[].denom The abbreviation of the currency, which are usually {#}GP, which when {#} is replaced with the number it becomes 5GP.
* @param {string} currencies[].percent The cost of the currency is in percentage (for work the 'abbreviation' property must includes '%' substring)
* @returns {string} An array of object containing the data and quantity for each currency
*/
Expand Down
2 changes: 1 addition & 1 deletion src/API/private-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,7 @@ export default class PrivateAPI {
foundry.utils.setProperty(flagData, "x", dropData.gridPosition?.x ?? 0);
foundry.utils.setProperty(flagData, "y", dropData.gridPosition?.y ?? 0);
}
foundry.utils.setProperty(dropData.itemData, "flags", flagData);
foundry.utils.setProperty(dropData.itemData, CONSTANTS.FLAGS.ITEM, flagData);

if (sourceActor) {
return game.itempiles.API.transferItems(sourceActor, targetActor, [dropData.itemData], { interactionId: dropData.interactionId });
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/pile-utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -1953,7 +1953,7 @@ export async function rollTable({
if (existingItem) {
existingItem.quantity += Math.max(newItem.quantity, 1);
} else {
setProperty(newItem, "flags", newItem.item.flags);
setProperty(newItem, CONSTANTS.FLAGS.ITEM, getProperty(newItem.item, CONSTANTS.FLAGS.ITEM));
if (game.itempiles.API.QUANTITY_FOR_PRICE_ATTRIBUTE && !getProperty(newItem, game.itempiles.API.QUANTITY_FOR_PRICE_ATTRIBUTE)) {
setProperty(newItem, game.itempiles.API.QUANTITY_FOR_PRICE_ATTRIBUTE, Utilities.getItemQuantity(newItem.item));
}
Expand Down Expand Up @@ -2044,7 +2044,7 @@ export async function rollMerchantTables({ tableData = false, actor = false } =
if (existingItem) {
existingItem.quantity += Math.max(newItem.quantity, 1);
} else {
setProperty(newItem, "flags", newItem.item.flags);
setProperty(newItem, CONSTANTS.FLAGS.ITEM, newItem.item.flags);
if (game.itempiles.API.QUANTITY_FOR_PRICE_ATTRIBUTE && !getProperty(newItem, game.itempiles.API.QUANTITY_FOR_PRICE_ATTRIBUTE)) {
setProperty(newItem, game.itempiles.API.QUANTITY_FOR_PRICE_ATTRIBUTE, Utilities.getItemQuantity(newItem.item));
}
Expand Down
7 changes: 3 additions & 4 deletions src/helpers/transaction.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as Utilities from "./utilities.js";
import * as PileUtilities from "./pile-utilities.js";
import { areItemsColliding, getItemFlagData } from "./pile-utilities.js";
import ItemPileSocket from "../socket.js";
import PrivateAPI from "../API/private-api.js";
import { SYSTEMS } from "../systems.js";
Expand Down Expand Up @@ -56,7 +55,7 @@ export default class Transaction {
foundry.utils.getProperty(itemData, CONSTANTS.FLAGS.ITEM + ".y") === undefined
)
||
areItemsColliding(item, itemData)
PileUtilities.areItemsColliding(item, itemData)
)
});
} else {
Expand Down Expand Up @@ -181,8 +180,8 @@ export default class Transaction {

this.itemDeltas = Array.from(this.itemDeltas).map(([id, quantity]) => {
const item = this.actor.items.get(id).toObject();
const existingFlagData = getItemFlagData(item);
const newFlagData = this.itemFlagMap.get(id) ?? {};
const existingFlagData = PileUtilities.cleanItemFlagData(PileUtilities.getItemFlagData(item));
const newFlagData = PileUtilities.cleanItemFlagData(this.itemFlagMap.get(id) ?? {});
setProperty(item, CONSTANTS.FLAGS.ITEM, foundry.utils.mergeObject(existingFlagData, newFlagData));
const type = this.itemTypeMap.get(id);
Utilities.setItemQuantity(item, quantity, true);
Expand Down
4 changes: 1 addition & 3 deletions src/stores/vault-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,6 @@ export class VaultStore extends ItemPileStore {

async onDropData(data, event, isExpander) {

debugger;

let validPosition = get(this.dragPosition);
this.dragPosition.set({ x: 0, y: 0, w: 1, h: 1, flipped: false, active: false });

Expand Down Expand Up @@ -546,7 +544,7 @@ export class VaultItem extends PileItem {
setProperty(flags, "x", x);
setProperty(flags, "y", y);
setProperty(flags, "flipped", flipped);
setProperty(itemData, "flags", flags);
setProperty(itemData, CONSTANTS.FLAGS.ITEM, flags);

await game.itempiles.API.addItems(this.store.actor, [{
item: itemData, quantity
Expand Down

0 comments on commit bcb78ac

Please sign in to comment.