summaryrefslogtreecommitdiff
path: root/dsa/DSALib/Auxiliary/Dice.cs
diff options
context:
space:
mode:
Diffstat (limited to 'dsa/DSALib/Auxiliary/Dice.cs')
-rw-r--r--dsa/DSALib/Auxiliary/Dice.cs20
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;
}