2017-04-21 22:51:30 +02:00
|
|
|
|
using System;
|
2017-10-25 00:58:59 +02:00
|
|
|
|
using System.Collections.Generic;
|
2017-10-26 00:55:04 +02:00
|
|
|
|
using System.Linq;
|
2017-04-21 22:51:30 +02:00
|
|
|
|
|
|
|
|
|
namespace Geekbot.net.Lib
|
|
|
|
|
{
|
2017-10-25 00:58:59 +02:00
|
|
|
|
internal class LevelCalc : ILevelCalc
|
2017-04-21 22:51:30 +02:00
|
|
|
|
{
|
2017-10-25 00:58:59 +02:00
|
|
|
|
private int[] _levels;
|
|
|
|
|
|
|
|
|
|
public LevelCalc()
|
2017-04-21 22:51:30 +02:00
|
|
|
|
{
|
2017-10-25 00:58:59 +02:00
|
|
|
|
var levels = new List<int>();
|
2017-04-21 22:51:30 +02:00
|
|
|
|
double total = 0;
|
2017-10-25 00:58:59 +02:00
|
|
|
|
for (var i = 1; i < 120; i++)
|
|
|
|
|
{
|
2017-04-21 22:51:30 +02:00
|
|
|
|
total += Math.Floor(i + 300 * Math.Pow(2, i / 7.0));
|
2017-10-25 00:58:59 +02:00
|
|
|
|
levels.Add((int) Math.Floor(total / 16));
|
|
|
|
|
}
|
|
|
|
|
_levels = levels.ToArray();
|
2017-04-21 22:51:30 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-26 00:55:04 +02:00
|
|
|
|
public int GetLevel(int messages)
|
2017-04-21 22:51:30 +02:00
|
|
|
|
{
|
2017-10-25 00:58:59 +02:00
|
|
|
|
var returnVal = 1;
|
|
|
|
|
foreach (var level in _levels)
|
|
|
|
|
{
|
2017-10-26 00:55:04 +02:00
|
|
|
|
if (level > messages) break;
|
2017-10-25 00:58:59 +02:00
|
|
|
|
returnVal++;
|
|
|
|
|
}
|
|
|
|
|
return returnVal;
|
2017-04-21 22:51:30 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-10-25 00:58:59 +02:00
|
|
|
|
|
|
|
|
|
public interface ILevelCalc
|
|
|
|
|
{
|
2017-10-26 00:55:04 +02:00
|
|
|
|
int GetLevel(int experience);
|
2017-10-25 00:58:59 +02:00
|
|
|
|
}
|
2017-09-15 22:56:03 +02:00
|
|
|
|
}
|