0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 09:50:43 -05:00

Improved emulation of flea,

Added `sellSum + notSellSum` values to profiles + wired up
This commit is contained in:
Chomp 2025-01-20 09:48:26 +00:00
parent fa31006761
commit c9631e30a1
5 changed files with 24 additions and 11 deletions

View File

@ -636,7 +636,7 @@ export class GameController {
/** /**
* Mechanic sends players a measuring tape on profile start for some reason * Mechanic sends players a measuring tape on profile start for some reason
* @param pmcProfile * @param pmcProfile Player profile
*/ */
protected sendMechanicGiftsToNewProfile(pmcProfile: IPmcData) { protected sendMechanicGiftsToNewProfile(pmcProfile: IPmcData) {
this.giftService.sendGiftWithSilentReceivedCheck("MechanicGiftDay1", pmcProfile.sessionId, 1); this.giftService.sendGiftWithSilentReceivedCheck("MechanicGiftDay1", pmcProfile.sessionId, 1);

View File

@ -531,19 +531,24 @@ export class RagfairOfferHelper {
/** /**
* Complete the selling of players' offer * Complete the selling of players' offer
* @param sessionID Session id * @param offerOwnerSessionId Session id
* @param offer Sold offer details * @param offer Sold offer details
* @param boughtAmount Amount item was purchased for * @param boughtAmount Amount item was purchased for
* @returns IItemEventRouterResponse * @returns IItemEventRouterResponse
*/ */
public completeOffer(sessionID: string, offer: IRagfairOffer, boughtAmount: number): IItemEventRouterResponse { public completeOffer(
offerOwnerSessionId: string,
offer: IRagfairOffer,
boughtAmount: number,
): IItemEventRouterResponse {
const itemTpl = offer.items[0]._tpl; const itemTpl = offer.items[0]._tpl;
let paymentItemsToSendToPlayer: IItem[] = []; let paymentItemsToSendToPlayer: IItem[] = [];
const offerStackCount = offer.items[0].upd.StackObjectsCount; const offerStackCount = offer.items[0].upd.StackObjectsCount;
const sellerProfile = this.profileHelper.getPmcProfile(offerOwnerSessionId);
// Pack or ALL items of a multi-offer were bought - remove entire ofer // Pack or ALL items of a multi-offer were bought - remove entire ofer
if (offer.sellInOnePiece || boughtAmount === offerStackCount) { if (offer.sellInOnePiece || boughtAmount === offerStackCount) {
this.deleteOfferById(sessionID, offer._id); this.deleteOfferById(offerOwnerSessionId, offer._id);
} else { } else {
const offerRootItem = offer.items[0]; const offerRootItem = offer.items[0];
@ -578,24 +583,26 @@ export class RagfairOfferHelper {
const ragfairDetails = { const ragfairDetails = {
offerId: offer._id, offerId: offer._id,
count: offer.sellInOnePiece ? offerStackCount : boughtAmount, // pack-offers NEED to the full item count otherwise it only removes 1 from the pack, leaving phantom offer on client ui count: offer.sellInOnePiece ? offerStackCount : boughtAmount, // pack-offers NEED to to be the full item count otherwise it only removes 1 from the pack, leaving phantom offer on client ui
handbookId: itemTpl, handbookId: itemTpl,
}; };
this.mailSendService.sendDirectNpcMessageToPlayer( this.mailSendService.sendDirectNpcMessageToPlayer(
sessionID, offerOwnerSessionId,
this.traderHelper.getTraderById(Traders.RAGMAN), this.traderHelper.getTraderById(Traders.RAGMAN),
MessageType.FLEAMARKET_MESSAGE, MessageType.FLEAMARKET_MESSAGE,
this.getLocalisedOfferSoldMessage(itemTpl, boughtAmount), this.getLocalisedOfferSoldMessage(itemTpl, boughtAmount),
paymentItemsToSendToPlayer, paymentItemsToSendToPlayer,
this.timeUtil.getHoursAsSeconds( this.timeUtil.getHoursAsSeconds(this.questHelper.getMailItemRedeemTimeHoursForProfile(sellerProfile)),
this.questHelper.getMailItemRedeemTimeHoursForProfile(this.profileHelper.getPmcProfile(sessionID)),
),
undefined, undefined,
ragfairDetails, ragfairDetails,
); );
return this.eventOutputHolder.getOutput(sessionID); // Adjust sellers sell sum values
sellerProfile.RagfairInfo.sellSum ||= 0;
sellerProfile.RagfairInfo.sellSum += offer.summaryCost;
return this.eventOutputHolder.getOutput(offerOwnerSessionId);
} }
/** /**

View File

@ -476,6 +476,8 @@ export interface ITraderInfo {
export interface IRagfairInfo { export interface IRagfairInfo {
rating: number; rating: number;
isRatingGrowing: boolean; isRatingGrowing: boolean;
sellSum: number;
notSellSum: number;
offers: IRagfairOffer[]; offers: IRagfairOffer[];
} }

View File

@ -99,7 +99,7 @@ export class RagfairServer {
offer.locked = true; offer.locked = true;
} }
public getOffer(offerID: string): IRagfairOffer { public getOffer(offerID: string): IRagfairOffer | undefined {
return this.ragfairOfferService.getOfferByOfferId(offerID); return this.ragfairOfferService.getOfferByOfferId(offerID);
} }

View File

@ -246,6 +246,10 @@ export class RagfairOfferService {
profile.RagfairInfo.rating -= this.databaseService.getGlobals().config.RagFair.ratingDecreaseCount; profile.RagfairInfo.rating -= this.databaseService.getGlobals().config.RagFair.ratingDecreaseCount;
profile.RagfairInfo.isRatingGrowing = false; profile.RagfairInfo.isRatingGrowing = false;
// Increment players 'notSellSum' value
profile.RagfairInfo.notSellSum ||= 0;
profile.RagfairInfo.notSellSum += playerOffer.summaryCost;
const firstOfferItem = playerOffer.items[0]; const firstOfferItem = playerOffer.items[0];
if (firstOfferItem.upd.StackObjectsCount > firstOfferItem.upd.OriginalStackObjectsCount) { if (firstOfferItem.upd.StackObjectsCount > firstOfferItem.upd.OriginalStackObjectsCount) {
playerOffer.items[0].upd.StackObjectsCount = firstOfferItem.upd.OriginalStackObjectsCount; playerOffer.items[0].upd.StackObjectsCount = firstOfferItem.upd.OriginalStackObjectsCount;