Removed module projects because it can't work like that atm. Commented out package commands.
This commit is contained in:
43
NadekoBot.Core/Modules/Xp/Common/LevelStats.cs
Normal file
43
NadekoBot.Core/Modules/Xp/Common/LevelStats.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using NadekoBot.Modules.Xp.Services;
|
||||
using System;
|
||||
|
||||
namespace NadekoBot.Modules.Xp.Common
|
||||
{
|
||||
public class LevelStats
|
||||
{
|
||||
public int Level { get; }
|
||||
public int LevelXp { get; }
|
||||
public int RequiredXp { get; }
|
||||
public int TotalXp { get; }
|
||||
|
||||
public LevelStats(int xp)
|
||||
{
|
||||
if (xp < 0)
|
||||
xp = 0;
|
||||
|
||||
TotalXp = xp;
|
||||
|
||||
const int baseXp = XpService.XP_REQUIRED_LVL_1;
|
||||
|
||||
var required = baseXp;
|
||||
var totalXp = 0;
|
||||
var lvl = 1;
|
||||
while (true)
|
||||
{
|
||||
required = (int)(baseXp + baseXp / 4.0 * (lvl - 1));
|
||||
|
||||
if (required + totalXp > xp)
|
||||
break;
|
||||
|
||||
totalXp += required;
|
||||
lvl++;
|
||||
}
|
||||
|
||||
Level = lvl - 1;
|
||||
LevelXp = xp - totalXp;
|
||||
RequiredXp = required;
|
||||
}
|
||||
|
||||
public static LevelStats FromXp(int xp) => new LevelStats(xp);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user