Global usings and file scoped namespaces

This commit is contained in:
Kwoth
2021-12-19 05:14:11 +01:00
parent bc31dae965
commit ee33313519
548 changed files with 47528 additions and 49115 deletions

View File

@@ -1,47 +1,43 @@
using System;
using System.Linq;
namespace NadekoBot.Modules.Gambling.Common;
namespace NadekoBot.Modules.Gambling.Common
public class Betroll
{
public class Betroll
public class Result
{
public class Result
{
public int Roll { get; set; }
public float Multiplier { get; set; }
public int Threshold { get; set; }
}
public int Roll { get; set; }
public float Multiplier { get; set; }
public int Threshold { get; set; }
}
private readonly IOrderedEnumerable<BetRollPair> _thresholdPairs;
private readonly Random _rng;
private readonly IOrderedEnumerable<BetRollPair> _thresholdPairs;
private readonly Random _rng;
public Betroll(BetRollConfig settings)
public Betroll(BetRollConfig settings)
{
_thresholdPairs = settings.Pairs.OrderByDescending(x => x.WhenAbove);
_rng = new Random();
}
public Result Roll()
{
var roll = _rng.Next(0, 101);
var pair = _thresholdPairs.FirstOrDefault(x => x.WhenAbove < roll);
if (pair is null)
{
_thresholdPairs = settings.Pairs.OrderByDescending(x => x.WhenAbove);
_rng = new Random();
}
public Result Roll()
{
var roll = _rng.Next(0, 101);
var pair = _thresholdPairs.FirstOrDefault(x => x.WhenAbove < roll);
if (pair is null)
{
return new Result
{
Multiplier = 0,
Roll = roll,
};
}
return new Result
{
Multiplier = pair.MultiplyBy,
Multiplier = 0,
Roll = roll,
Threshold = pair.WhenAbove,
};
}
return new Result
{
Multiplier = pair.MultiplyBy,
Roll = roll,
Threshold = pair.WhenAbove,
};
}
}