From ff7f711c885c6fc3c171244085eafc4925b26b62 Mon Sep 17 00:00:00 2001 From: Chomp Date: Fri, 24 Jan 2025 09:53:50 +0000 Subject: [PATCH] Cleanup of `CalculateLevel` --- Libraries/Core/Services/PlayerService.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Libraries/Core/Services/PlayerService.cs b/Libraries/Core/Services/PlayerService.cs index 0b521c71..8a58a826 100644 --- a/Libraries/Core/Services/PlayerService.cs +++ b/Libraries/Core/Services/PlayerService.cs @@ -1,7 +1,5 @@ -using SptCommon.Annotations; using Core.Models.Eft.Common; -using Core.Models.Utils; -using Core.Utils; +using SptCommon.Annotations; namespace Core.Services; @@ -10,13 +8,19 @@ public class PlayerService( DatabaseService _databaseService ) { + /** + * Get level of player + * @param pmcData Player profile + * @returns Level of player + */ public int? CalculateLevel(PmcData pmcData) { var accExp = 0; - for (int i = 0; i < _databaseService.GetGlobals().Configuration.Exp.Level.ExperienceTable.Length; i++) + var expTable = _databaseService.GetGlobals().Configuration.Exp.Level.ExperienceTable; + for (var i = 0; i < expTable.Length; i++) { - accExp += _databaseService.GetGlobals().Configuration.Exp.Level.ExperienceTable[i].Experience ?? 0; + accExp += expTable[i].Experience ?? 0; if (pmcData.Info.Experience < accExp) {