From 88a854c5caacdd5dd0166c9ad3e6e2244008c48e Mon Sep 17 00:00:00 2001 From: Dev Date: Mon, 29 May 2023 16:12:27 +0100 Subject: [PATCH] Refactor processOffersOnProfile() --- project/src/helpers/RagfairOfferHelper.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/project/src/helpers/RagfairOfferHelper.ts b/project/src/helpers/RagfairOfferHelper.ts index 08b6e4bb..3111d939 100644 --- a/project/src/helpers/RagfairOfferHelper.ts +++ b/project/src/helpers/RagfairOfferHelper.ts @@ -4,7 +4,7 @@ import { IPmcData } from "../models/eft/common/IPmcData"; import { Item } from "../models/eft/common/tables/IItem"; import { ITraderAssort } from "../models/eft/common/tables/ITrader"; import { IItemEventRouterResponse } from "../models/eft/itemEvent/IItemEventRouterResponse"; -import { ISystemData } from "../models/eft/profile/IAkiProfile"; +import { IAkiProfile, ISystemData } from "../models/eft/profile/IAkiProfile"; import { IRagfairOffer } from "../models/eft/ragfair/IRagfairOffer"; import { ISearchRequestData, OfferOwnerType } from "../models/eft/ragfair/ISearchRequestData"; import { ConfigTypes } from "../models/enums/ConfigTypes"; @@ -246,10 +246,7 @@ export class RagfairOfferHelper boughtAmount = offer.sellResult[0].amount; } - // Increase rating - const profileRagfairInfo = this.saveServer.getProfile(sessionID).characters.pmc.RagfairInfo; - profileRagfairInfo.rating += this.ragfairConfig.sell.reputation.gain * offer.summaryCost / totalItemsCount * boughtAmount; - profileRagfairInfo.isRatingGrowing = true; + this.increaseProfileRagfairRating(this.saveServer.getProfile(sessionID), offer.summaryCost / totalItemsCount * boughtAmount); this.completeOffer(sessionID, offer, boughtAmount); offer.sellResult.splice(0, 1); @@ -261,6 +258,17 @@ export class RagfairOfferHelper return true; } + /** + * Add amount to players ragfair rating + * @param sessionId Profile to update + * @param amountToIncrementBy Raw amount to add to players ragfair rating (excluding the reputation gain multiplier) + */ + public increaseProfileRagfairRating(profile: IAkiProfile, amountToIncrementBy: number): void + { + profile.characters.pmc.RagfairInfo.rating += this.ragfairConfig.sell.reputation.gain * amountToIncrementBy; + profile.characters.pmc.RagfairInfo.isRatingGrowing = true; + } + protected getProfileOffers(sessionID: string): IRagfairOffer[] { const profile = this.profileHelper.getPmcProfile(sessionID);