Fix the server sell all price not matching the client displayed value (!216)
Resolved by having the client send the sell price instead of trying to calculate it on the server. Same route, just with an extra parameter passed in Removed unnecessary value calculation code, and renamed method to match new behaviour Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/216 Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com> Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
7a33eea672
commit
bc8e98dadc
@ -262,55 +262,24 @@ export class TradeController
|
||||
): IItemEventRouterResponse
|
||||
{
|
||||
const output = this.eventOutputHolder.getOutput(sessionId);
|
||||
const scavProfile = this.profileHelper.getFullProfile(sessionId)?.characters?.scav;
|
||||
if (!scavProfile)
|
||||
{
|
||||
return this.httpResponse.appendErrorToOutput(output, `Profile ${request.fromOwner.id} has no scav account`);
|
||||
}
|
||||
|
||||
this.calculateCostOfScavInventoryAndMailMoneyToPlayer(sessionId, scavProfile, Traders.FENCE);
|
||||
this.mailMoneyToPlayer(sessionId, request.totalValue, Traders.FENCE);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cost of items in inventory and send rouble total to player as mail
|
||||
* Send the specified rouble total to player as mail
|
||||
* @param sessionId Session id
|
||||
* @param profileWithItemsToSell Profile with items to be sold to trader
|
||||
* @param profileThatGetsMoney Profile that gets the money after selling items
|
||||
* @param trader Trader to sell items to
|
||||
* @param output IItemEventRouterResponse
|
||||
*/
|
||||
protected calculateCostOfScavInventoryAndMailMoneyToPlayer(
|
||||
protected mailMoneyToPlayer(
|
||||
sessionId: string,
|
||||
profileWithItemsToSell: IPmcData,
|
||||
roublesToSend: number,
|
||||
trader: Traders,
|
||||
): void
|
||||
{
|
||||
const handbookPrices = this.ragfairPriceService.getAllStaticPrices();
|
||||
// TODO, apply trader sell bonuses?
|
||||
const traderDetails = this.traderHelper.getTrader(trader, sessionId);
|
||||
|
||||
// Get all base items that scav has (primaryweapon/backpack/pockets etc)
|
||||
// Add items that trader will buy (only sell items that have the container as parent) to request object
|
||||
let roublesToSend = 0;
|
||||
const containerAndEquipmentItems = profileWithItemsToSell.Inventory.items.filter((item) =>
|
||||
item.parentId === profileWithItemsToSell.Inventory.equipment
|
||||
);
|
||||
for (const itemToSell of containerAndEquipmentItems)
|
||||
{
|
||||
// Increment sell price in request
|
||||
roublesToSend += this.getPriceOfItemAndChildren(
|
||||
itemToSell._id,
|
||||
profileWithItemsToSell.Inventory.items,
|
||||
handbookPrices,
|
||||
traderDetails,
|
||||
);
|
||||
}
|
||||
|
||||
// Server-side calcualted isnt matching clientside calcualtion, temp fix to get it to be closer
|
||||
roublesToSend /= 2;
|
||||
|
||||
this.logger.debug(`Selling scav items to fence for ${roublesToSend} roubles`);
|
||||
|
||||
// Create single currency item with all currency on it
|
||||
|
@ -3,6 +3,7 @@ import { OwnerInfo } from "@spt-aki/models/eft/common/request/IBaseInteractionRe
|
||||
export interface ISellScavItemsToFenceRequestData
|
||||
{
|
||||
Action: "SellAllFromSavage";
|
||||
totalValue: number;
|
||||
fromOwner: OwnerInfo;
|
||||
toOwner: OwnerInfo;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user