Prevent giving player 0 intellet as reward after repairing item

This commit is contained in:
Dev 2023-12-11 11:46:54 +00:00
parent 73cfc16699
commit 2cebf5f2ee

View File

@ -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);
}
/**