Split Geekbot.net into src/Bot, src/Core, and src/Web

This commit is contained in:
runebaas 2020-08-08 22:24:01 +02:00
parent 7b6dd2d2f9
commit fc0af492ad
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
197 changed files with 542 additions and 498 deletions

View file

@ -0,0 +1,7 @@
namespace Geekbot.Core.Levels
{
public interface ILevelCalc
{
int GetLevel(int? experience);
}
}

View 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();
}
}
}