From e6181c24124d97f2fbc932b8a68311e625463156 Mon Sep 17 00:00:00 2001 From: uzvkl Date: Tue, 11 Jun 2019 23:05:52 +0200 Subject: Move dsa related stuff to subfolder --- DSALib/Auxiliary/Dice.cs | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 DSALib/Auxiliary/Dice.cs (limited to 'DSALib/Auxiliary/Dice.cs') diff --git a/DSALib/Auxiliary/Dice.cs b/DSALib/Auxiliary/Dice.cs deleted file mode 100644 index 0bfabeb..0000000 --- a/DSALib/Auxiliary/Dice.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Linq; - -namespace DSALib.Auxiliary -{ - public static class Dice // roll it! - { - 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(); - - - if (strings.Count != 2) - throw new ArgumentException($"{input}: does not satisfy the format requirements( dice count (d|w) die size)"); - - var count = Convert.ToInt32(strings[0]); - var d = Convert.ToInt32(strings[0]); - - return Roll(count, d); - } - - public static int Roll(int count, int d) - { - if (d <= 0 || count <= 0) return 0; - - var sum = 0; - for (var i = 0; i < Math.Abs(count); i++) - { - var roll = Roll(d); - sum += roll; - } - - sum *= Math.Abs(count) / count; - - return sum; - } - } -} \ No newline at end of file -- cgit v1.2.3-70-g09d2