From f89f308c525e9deebc6d2cf6416e27dfe1a299dc Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Sun, 19 May 2019 16:03:38 +0200 Subject: Cleanup DiscoBot Project --- DSACore/Auxiliary/Dice.cs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'DSACore/Auxiliary/Dice.cs') diff --git a/DSACore/Auxiliary/Dice.cs b/DSACore/Auxiliary/Dice.cs index 2df8aa7..3dd6562 100644 --- a/DSACore/Auxiliary/Dice.cs +++ b/DSACore/Auxiliary/Dice.cs @@ -5,7 +5,7 @@ namespace DSACore.Auxiliary { public static class Dice // roll it! { - private static readonly System.Random Rnd = new System.Random(); + private static readonly Random Rnd = new Random(); public static int Roll(int d = 20) { @@ -14,29 +14,24 @@ namespace DSACore.Auxiliary public static int Roll(string input) { - var strings = input.ToLower().Split(new[] { 'w', 'd' }, 2, StringSplitOptions.RemoveEmptyEntries).ToList(); - int count = Convert.ToInt32(strings[0]); - int d = Convert.ToInt32(strings[0]); + var strings = input.ToLower().Split(new[] {'w', 'd'}, 2, StringSplitOptions.RemoveEmptyEntries).ToList(); + var count = Convert.ToInt32(strings[0]); + var d = Convert.ToInt32(strings[0]); if (strings.Count != 2) - { throw new ArgumentException($"{input}: erfüllt nicht die Formatvogaben( Anzahl d Augenzahl)"); - } return Roll(count, d); } public static int Roll(int count, int d) { - if (d <= 0) - { - return 0; - } + if (d <= 0) return 0; - int sum = 0; - for (int i = 0; i < Math.Abs(count); i++) + var sum = 0; + for (var i = 0; i < Math.Abs(count); i++) { - var roll = Dice.Roll(d); + var roll = Roll(d); sum += roll; } @@ -45,4 +40,4 @@ namespace DSACore.Auxiliary return sum; } } -} +} \ No newline at end of file -- cgit v1.2.3-70-g09d2