using SPTarkov.Common.Annotations; using SPTarkov.Server.Core.Models.Eft.Common; namespace SPTarkov.Server.Core.Services; [Injectable(InjectionType.Singleton)] public class PlayerService( DatabaseService _databaseService ) { /// /// Calculates the current level of a player based on their accumulated experience points. /// This method iterates through an experience table to determine the highest level achieved /// by comparing the player's experience against cumulative thresholds. /// /// Player profile /// /// The calculated level of the player as an integer, or null if the level cannot be determined. /// This value is also assigned to within the provided profile. /// public int? CalculateLevel(PmcData pmcData) { var accExp = 0; var expTable = _databaseService.GetGlobals().Configuration.Exp.Level.ExperienceTable; for (var i = 0; i < expTable.Length; i++) { accExp += expTable[i].Experience ?? 0; if (pmcData.Info.Experience < accExp) { break; } pmcData.Info.Level = i + 1; } return pmcData.Info.Level; } }