Skip to content

Instantly share code, notes, and snippets.

@acid-chicken
Last active September 9, 2018 15:05
Show Gist options
  • Save acid-chicken/2778b769644a0d777c786945bca5fa40 to your computer and use it in GitHub Desktop.
Save acid-chicken/2778b769644a0d777c786945bca5fa40 to your computer and use it in GitHub Desktop.
334 Reporter
public class PointCalculator
{
private int _power, _penalty;
public PointCalculator(int power = 1, int penalty = 2)
{
_power = power;
_penalty = penalty == default ? 1 : penalty;
}
public int Calculate(TimeSpan delay)
{
var duration = delay.Duration().TotalMilliseconds;
return (int)Math.Floor(_power * (
duration < 10 ? 1000 - duration * 10 :
duration < 100 ? 940 - duration * 4 :
duration < 1000 ? 565 - duration / 4 :
duration < 10000 ? 325 - duration / 100 :
duration < 60000 ? 245 - duration / 500 : 0) / (
delay == delay.Duration() ? 1 : _penalty));
}
}
public int Rank => RankBorder.Select((b, i) => (b, i)).FirstOrDefault(x => x.b > Exp).i - 1;
public static IList<int> RankBorder => Enumerable.Range(0, 1000).Select(x => (x + 15) * x * 40).ToList();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment