diff options
author | Dennis Kobert <d-kobert@web.de> | 2019-06-12 21:47:51 +0200 |
---|---|---|
committer | Dennis Kobert <d-kobert@web.de> | 2019-06-12 21:47:51 +0200 |
commit | 304437b834e8c87687f68333ae67a13ee1377a73 (patch) | |
tree | 51dd246568e8a159627d9cb92e99890adb5cbef8 /dsa/DSALib/Auxiliary/Dice.cs | |
parent | 2fa4a0e50ebfc97059c8b84dbd17e79f9afc8a8d (diff) |
Adjust Codestyle
Diffstat (limited to 'dsa/DSALib/Auxiliary/Dice.cs')
-rw-r--r-- | dsa/DSALib/Auxiliary/Dice.cs | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/dsa/DSALib/Auxiliary/Dice.cs b/dsa/DSALib/Auxiliary/Dice.cs index 0bfabeb..36a4748 100644 --- a/dsa/DSALib/Auxiliary/Dice.cs +++ b/dsa/DSALib/Auxiliary/Dice.cs @@ -1,24 +1,22 @@ using System; using System.Linq; -namespace DSALib.Auxiliary -{ +namespace DSALib.Auxiliary { public static class Dice // roll it! { private static readonly Random Rnd = new Random(); - public static int Roll(int d = 20) - { + public static int Roll(int d = 20) { return Rnd.Next(d) + 1; } - public static int Roll(string input) - { + 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)"); + 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]); @@ -26,13 +24,11 @@ namespace DSALib.Auxiliary return Roll(count, d); } - public static int Roll(int count, int 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++) - { + for (var i = 0; i < Math.Abs(count); i++) { var roll = Roll(d); sum += roll; } |