From b478a1cdade96ad17560c0bab3604e467676c606 Mon Sep 17 00:00:00 2001 From: Dev Date: Tue, 13 Jun 2023 19:33:42 +0100 Subject: [PATCH] Add nan check to ragfair rating incrementor code --- project/src/helpers/RagfairOfferHelper.ts | 8 +++++++- project/src/helpers/RagfairSellHelper.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/project/src/helpers/RagfairOfferHelper.ts b/project/src/helpers/RagfairOfferHelper.ts index 48eaa82d..8e7107ef 100644 --- a/project/src/helpers/RagfairOfferHelper.ts +++ b/project/src/helpers/RagfairOfferHelper.ts @@ -278,8 +278,14 @@ export class RagfairOfferHelper */ public increaseProfileRagfairRating(profile: IAkiProfile, amountToIncrementBy: number): void { - profile.characters.pmc.RagfairInfo.rating += this.ragfairConfig.sell.reputation.gain * amountToIncrementBy; profile.characters.pmc.RagfairInfo.isRatingGrowing = true; + if (isNaN(amountToIncrementBy)) + { + this.logger.warning(`Unable to increment ragfair rating, value was not a number: ${amountToIncrementBy}`); + + return; + } + profile.characters.pmc.RagfairInfo.rating += this.ragfairConfig.sell.reputation.gain * amountToIncrementBy; } /** diff --git a/project/src/helpers/RagfairSellHelper.ts b/project/src/helpers/RagfairSellHelper.ts index bcb04714..4ab4ce0b 100644 --- a/project/src/helpers/RagfairSellHelper.ts +++ b/project/src/helpers/RagfairSellHelper.ts @@ -80,7 +80,7 @@ export class RagfairSellHelper sellChancePercent = this.ragfairConfig.sell.chance.base; } - this.logger.debug(`Rolling to sell ${itemSellCount} items (chance: ${sellChancePercent}%)`); + this.logger.debug(`Rolling to sell: ${itemSellCount} items (chance: ${sellChancePercent}%)`); // No point rolling for a sale on a 0% chance item, exit early if (sellChancePercent === 0)