diff options
author | natrixaeria <janng@gmx.de> | 2019-05-19 17:40:59 +0200 |
---|---|---|
committer | natrixaeria <janng@gmx.de> | 2019-05-19 17:40:59 +0200 |
commit | 1509b5ef3d7e9e71d9294e234ec0e39f2d831998 (patch) | |
tree | 78300ffff230958101b422a4e6026925b287822f /DiscoBot/Auxiliary/Dice.cs | |
parent | c3bb858bb54dc8c64bbd48054c2c58dc0073f09c (diff) | |
parent | c4d046858e0822b7c2c540ac2368b2c0e88e7a26 (diff) |
Merge branch 'scribble' of https://github.com/TrueDoctor/DiscoBot into scribble
Diffstat (limited to 'DiscoBot/Auxiliary/Dice.cs')
-rw-r--r-- | DiscoBot/Auxiliary/Dice.cs | 37 |
1 files changed, 9 insertions, 28 deletions
diff --git a/DiscoBot/Auxiliary/Dice.cs b/DiscoBot/Auxiliary/Dice.cs index 0cd9656..f0f4def 100644 --- a/DiscoBot/Auxiliary/Dice.cs +++ b/DiscoBot/Auxiliary/Dice.cs @@ -1,44 +1,25 @@ -namespace DiscoBot.Auxiliary -{ - using System; - using System.Linq; - - using Discord.Commands; +using System; +namespace DiscoBot.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) { return Rnd.Next(d) + 1; } - 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]); - - 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; } @@ -47,4 +28,4 @@ return sum; } } -} +}
\ No newline at end of file |