Improved logic of getBonusValueFromProfile()

(cherry picked from commit 2a52af1275)
This commit is contained in:
Dev 2024-08-08 22:36:32 +01:00
parent d97e717f76
commit 0e1094d775

View File

@ -509,9 +509,13 @@ export class ProfileHelper {
*/
public getBonusValueFromProfile(pmcProfile: IPmcData, desiredBonus: BonusType): number {
const bonuses = pmcProfile.Bonuses.filter((bonus) => bonus.type === desiredBonus);
if (!bonuses)
{
return 0;
}
// Sum all bonuses found above
return bonuses?.reduce((sum, curr) => sum + (curr.value ?? 0), 100) ?? 0;
return bonuses.reduce((sum, curr) => sum + (curr.value ?? 0), 0);
}
public playerIsFleaBanned(pmcProfile: IPmcData): boolean {