34 lines
804 B
C#
34 lines
804 B
C#
namespace DataServer.Data.Entities;
|
|
|
|
/// <summary>
|
|
/// Experience required per level (exponential curve)
|
|
/// </summary>
|
|
public static class LevelSystem
|
|
{
|
|
public static long GetXpForLevel(int level)
|
|
{
|
|
// Base 100 XP for level 2, scaling exponentially
|
|
return (long)(100 * Math.Pow(1.15, level - 1));
|
|
}
|
|
|
|
public static long GetTotalXpForLevel(int level)
|
|
{
|
|
long total = 0;
|
|
for (int i = 1; i < level; i++)
|
|
total += GetXpForLevel(i);
|
|
return total;
|
|
}
|
|
|
|
public static int GetLevelForXp(long totalXp)
|
|
{
|
|
int level = 1;
|
|
long xpNeeded = 0;
|
|
while (xpNeeded <= totalXp)
|
|
{
|
|
xpNeeded += GetXpForLevel(level);
|
|
if (xpNeeded <= totalXp) level++;
|
|
}
|
|
return level;
|
|
}
|
|
}
|