Split Geekbot.net into src/Bot, src/Core, and src/Web
This commit is contained in:
parent
7b6dd2d2f9
commit
fc0af492ad
197 changed files with 542 additions and 498 deletions
7
src/Core/Levels/ILevelCalc.cs
Normal file
7
src/Core/Levels/ILevelCalc.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
namespace Geekbot.Core.Levels
|
||||
{
|
||||
public interface ILevelCalc
|
||||
{
|
||||
int GetLevel(int? experience);
|
||||
}
|
||||
}
|
28
src/Core/Levels/LevelCalc.cs
Normal file
28
src/Core/Levels/LevelCalc.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Geekbot.Core.Levels
|
||||
{
|
||||
public class LevelCalc : ILevelCalc
|
||||
{
|
||||
private readonly int[] _levels;
|
||||
|
||||
public LevelCalc()
|
||||
{
|
||||
var levels = new List<int>();
|
||||
double total = 0;
|
||||
for (var i = 1; i < 120; i++)
|
||||
{
|
||||
total += Math.Floor(i + 300 * Math.Pow(2, i / 7.0));
|
||||
levels.Add((int) Math.Floor(total / 16));
|
||||
}
|
||||
_levels = levels.ToArray();
|
||||
}
|
||||
|
||||
public int GetLevel(int? messages)
|
||||
{
|
||||
return 1 + _levels.TakeWhile(level => !(level > messages)).Count();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue