Skip to content

Commit

Permalink
Fixed offer quantity only updating when trader offer had buy restrict…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
Chomp committed Feb 21, 2025
1 parent be80033 commit b37900d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions project/src/helpers/TradeHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,33 @@ export class TradeHelper {

// We store ragfair offerid in buyRequestData.item_id
const offerWithItem = allOffers.find((x) => x._id === buyRequestData.item_id);
const itemPurchased = offerWithItem.items[0];
const rootItemPurchased = offerWithItem.items[0];

// Update offer quantity
offerWithItem.quantity -= buyCount;

// Ensure purchase does not exceed trader item limit
const assortHasBuyRestrictions = this.itemHelper.hasBuyRestrictions(itemPurchased);
const assortHasBuyRestrictions = this.itemHelper.hasBuyRestrictions(rootItemPurchased);
if (assortHasBuyRestrictions) {
this.checkPurchaseIsWithinTraderItemLimit(
sessionID,
pmcData,
buyRequestData.tid,
itemPurchased,
rootItemPurchased,
buyRequestData.item_id,
buyCount,
);

// Decrement trader item count
// Decrement trader current purchase count in profile
const itemPurchaseDetails = {
items: [{ itemId: buyRequestData.item_id, count: buyCount }],
traderId: buyRequestData.tid,
};
this.traderHelper.addTraderPurchasesToPlayerProfile(sessionID, itemPurchaseDetails, itemPurchased);

// Update offer quantity
offerWithItem.quantity -= buyCount;
this.traderHelper.addTraderPurchasesToPlayerProfile(
sessionID,
itemPurchaseDetails,
rootItemPurchased,
);
}
};

Expand Down

0 comments on commit b37900d

Please sign in to comment.