diff --git a/project/src/services/RepairService.ts b/project/src/services/RepairService.ts index a5d6e113..7a7e2b11 100644 --- a/project/src/services/RepairService.ts +++ b/project/src/services/RepairService.ts @@ -147,6 +147,7 @@ export class RepairService */ public addRepairSkillPoints(sessionId: string, repairDetails: RepairDetails, pmcData: IPmcData): void { + // Handle kit repair of weapon if ( repairDetails.repairedByKit && this.itemHelper.isOfBaseclass(repairDetails.repairedItem._tpl, BaseClasses.WEAPON) @@ -160,7 +161,7 @@ export class RepairService } } - // Handle kit repairs of armor + // Handle kit repair of armor if ( repairDetails.repairedByKit && this.itemHelper.isOfBaseclasses(repairDetails.repairedItem._tpl, [BaseClasses.ARMOR, BaseClasses.VEST]) @@ -189,16 +190,25 @@ export class RepairService } // Handle giving INT to player - differs if using kit/trader and weapon vs armor - let intellectGainedFromRepair: number; + const intellectGainedFromRepair = this.getIntellectGainedFromRepair(repairDetails); + if (intellectGainedFromRepair > 0) + { + this.profileHelper.addSkillPointsToPlayer(pmcData, SkillTypes.INTELLECT, intellectGainedFromRepair); + } + } + + protected getIntellectGainedFromRepair(repairDetails: RepairDetails): number + { if (repairDetails.repairedByKit) { + // Weapons/armor have different multipliers const intRepairMultiplier = (this.itemHelper.isOfBaseclass(repairDetails.repairedItem._tpl, BaseClasses.WEAPON)) ? this.repairConfig.repairKitIntellectGainMultiplier.weapon : this.repairConfig.repairKitIntellectGainMultiplier.armor; - // limit gain to a max value defined in config.maxIntellectGainPerRepair - intellectGainedFromRepair = Math.min( + // Limit gain to a max value defined in config.maxIntellectGainPerRepair + return Math.min( repairDetails.repairPoints * intRepairMultiplier, this.repairConfig.maxIntellectGainPerRepair.kit, ); @@ -206,13 +216,11 @@ export class RepairService else { // Trader repair - Not as accurate as kit, needs data from live - intellectGainedFromRepair = Math.min( + return Math.min( repairDetails.repairAmount / 10, this.repairConfig.maxIntellectGainPerRepair.trader, ); } - - this.profileHelper.addSkillPointsToPlayer(pmcData, SkillTypes.INTELLECT, intellectGainedFromRepair); } /**