diff options
author | Dennis Kobert <d-kobert@web.de> | 2019-06-11 23:38:13 +0200 |
---|---|---|
committer | Dennis Kobert <d-kobert@web.de> | 2019-06-11 23:38:13 +0200 |
commit | 2fa4a0e50ebfc97059c8b84dbd17e79f9afc8a8d (patch) | |
tree | c3b34ccb2737e347a73768536895cbbaab13cc01 /DiscoBot/Auxiliary/Dice.cs | |
parent | ec991104f56e90d7bb2878da2fe6ed4e585dfc46 (diff) | |
parent | af74efccf8d21e6151022b71f3cacd3fa83024ee (diff) |
Merge branch 'rework-backend'
Diffstat (limited to 'DiscoBot/Auxiliary/Dice.cs')
-rw-r--r-- | DiscoBot/Auxiliary/Dice.cs | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/DiscoBot/Auxiliary/Dice.cs b/DiscoBot/Auxiliary/Dice.cs deleted file mode 100644 index 0cd9656..0000000 --- a/DiscoBot/Auxiliary/Dice.cs +++ /dev/null @@ -1,50 +0,0 @@ -namespace DiscoBot.Auxiliary -{ - using System; - using System.Linq; - - using Discord.Commands; - - public static class Dice // roll it! - { - private static readonly System.Random Rnd = new System.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; - } - - int sum = 0; - for (int i = 0; i < Math.Abs(count); i++) - { - var roll = Dice.Roll(d); - sum += roll; - } - - sum *= Math.Abs(count) / count; - - return sum; - } - } -} |