36 lines
824 B
C#
36 lines
824 B
C#
using SPTarkov.Server.Core.Models.Eft.Common;
|
|
using SPTarkov.Common.Annotations;
|
|
|
|
namespace SPTarkov.Server.Core.Services;
|
|
|
|
[Injectable(InjectionType.Singleton)]
|
|
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;
|
|
|
|
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;
|
|
}
|
|
}
|