Fix bug where setting ragfairconfig.purchasesAreFoundInRaid to true would make trader purchases on flea Found in raid
This commit is contained in:
parent
2410ddfe59
commit
48de3139ae
@ -93,26 +93,27 @@ class TradeController
|
|||||||
return this.httpResponse.appendErrorToOutput(output, errorMessage, BackendErrorCodes.OFFEROUTOFSTOCK);
|
return this.httpResponse.appendErrorToOutput(output, errorMessage, BackendErrorCodes.OFFEROUTOFSTOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip buying items when player doesn't have necessary loyalty
|
const sellerIsTrader = fleaOffer.user.memberType === MemberCategory.TRADER;
|
||||||
if (
|
|
||||||
fleaOffer.user.memberType === MemberCategory.TRADER
|
// Skip buying items when player doesn't have needed loyalty
|
||||||
&& fleaOffer.loyaltyLevel > pmcData.TradersInfo[fleaOffer.user.id].loyaltyLevel
|
if (sellerIsTrader && fleaOffer.loyaltyLevel > pmcData.TradersInfo[fleaOffer.user.id].loyaltyLevel)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
`Unable to buy item: ${
|
`Unable to buy item: ${
|
||||||
fleaOffer.items[0]._tpl
|
fleaOffer.items[0]._tpl
|
||||||
} from trader: ${fleaOffer.user.id} as loyalty level too low, skipping`,
|
} from trader: ${fleaOffer.user.id} as loyalty level too low, skipping`,
|
||||||
);
|
);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Log full purchase JSON
|
||||||
this.logger.debug(this.jsonUtil.serializeAdvanced(offer, null, 2));
|
this.logger.debug(this.jsonUtil.serializeAdvanced(offer, null, 2));
|
||||||
|
|
||||||
const buyData: IProcessBuyTradeRequestData = {
|
const buyData: IProcessBuyTradeRequestData = {
|
||||||
Action: "TradingConfirm",
|
Action: "TradingConfirm",
|
||||||
type: "buy_from_trader",
|
type: "buy_from_trader",
|
||||||
tid: (fleaOffer.user.memberType !== MemberCategory.TRADER) ? "ragfair" : fleaOffer.user.id,
|
tid: (sellerIsTrader) ? fleaOffer.user.id : "ragfair",
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
item_id: fleaOffer.root,
|
item_id: fleaOffer.root,
|
||||||
count: offer.count,
|
count: offer.count,
|
||||||
@ -121,18 +122,24 @@ class TradeController
|
|||||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||||
scheme_items: offer.items,
|
scheme_items: offer.items,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Trader / PMC offers use different found in raid config values
|
||||||
|
const purchasedItemFoundInRaid = (sellerIsTrader)
|
||||||
|
? this.traderConfig.purchasesAreFoundInRaid
|
||||||
|
: this.ragfairConfig.dynamic.purchasesAreFoundInRaid;
|
||||||
|
|
||||||
// confirmTrading() must occur prior to removing the offer stack, otherwise item inside offer doesn't exist for confirmTrading() to use
|
// confirmTrading() must occur prior to removing the offer stack, otherwise item inside offer doesn't exist for confirmTrading() to use
|
||||||
output = this.confirmTradingInternal(
|
output = this.confirmTradingInternal(
|
||||||
pmcData,
|
pmcData,
|
||||||
buyData,
|
buyData,
|
||||||
sessionID,
|
sessionID,
|
||||||
this.ragfairConfig.dynamic.purchasesAreFoundInRaid,
|
purchasedItemFoundInRaid,
|
||||||
fleaOffer.items[0].upd,
|
fleaOffer.items[0].upd,
|
||||||
);
|
);
|
||||||
if (fleaOffer.user.memberType !== MemberCategory.TRADER)
|
|
||||||
|
if (!sellerIsTrader)
|
||||||
{
|
{
|
||||||
// remove player item offer stack
|
// Remove the item purchased from flea offer
|
||||||
this.ragfairServer.removeOfferStack(fleaOffer._id, offer.count);
|
this.ragfairServer.removeOfferStack(fleaOffer._id, offer.count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,7 +150,7 @@ class TradeController
|
|||||||
/** Handle SellAllFromSavage event */
|
/** Handle SellAllFromSavage event */
|
||||||
public sellScavItemsToFence(
|
public sellScavItemsToFence(
|
||||||
pmcData: IPmcData,
|
pmcData: IPmcData,
|
||||||
body: ISellScavItemsToFenceRequestData,
|
request: ISellScavItemsToFenceRequestData,
|
||||||
sessionId: string,
|
sessionId: string,
|
||||||
): IItemEventRouterResponse
|
): IItemEventRouterResponse
|
||||||
{
|
{
|
||||||
@ -152,7 +159,7 @@ class TradeController
|
|||||||
{
|
{
|
||||||
return this.httpResponse.appendErrorToOutput(
|
return this.httpResponse.appendErrorToOutput(
|
||||||
this.eventOutputHolder.getOutput(sessionId),
|
this.eventOutputHolder.getOutput(sessionId),
|
||||||
`Profile ${body.fromOwner.id} has no scav account`,
|
`Profile ${request.fromOwner.id} has no scav account`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user