2017-04-21 22:51:30 +02:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Geekbot.net.Lib
|
|
|
|
|
{
|
2017-09-15 22:56:03 +02:00
|
|
|
|
internal class LevelCalc
|
2017-04-21 22:51:30 +02:00
|
|
|
|
{
|
|
|
|
|
private static int GetExperienceAtLevel(int level)
|
|
|
|
|
{
|
|
|
|
|
double total = 0;
|
2017-09-15 22:56:03 +02:00
|
|
|
|
for (var i = 1; i < level; i++)
|
2017-04-21 22:51:30 +02:00
|
|
|
|
total += Math.Floor(i + 300 * Math.Pow(2, i / 7.0));
|
|
|
|
|
|
2017-09-15 22:56:03 +02:00
|
|
|
|
return (int) Math.Floor(total / 16);
|
2017-04-21 22:51:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int GetLevelAtExperience(int experience)
|
|
|
|
|
{
|
|
|
|
|
int index;
|
|
|
|
|
|
|
|
|
|
for (index = 0; index < 120; index++)
|
|
|
|
|
if (GetExperienceAtLevel(index + 1) > experience)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
return index;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-15 22:56:03 +02:00
|
|
|
|
}
|