summaryrefslogtreecommitdiff
path: root/DiscordBot/Auxiliary/Dice.cs
diff options
context:
space:
mode:
Diffstat (limited to 'DiscordBot/Auxiliary/Dice.cs')
-rw-r--r--DiscordBot/Auxiliary/Dice.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/DiscordBot/Auxiliary/Dice.cs b/DiscordBot/Auxiliary/Dice.cs
new file mode 100644
index 0000000..c44e87e
--- /dev/null
+++ b/DiscordBot/Auxiliary/Dice.cs
@@ -0,0 +1,31 @@
+using System;
+
+namespace DiscordBot.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(int count, int d)
+ {
+ if (d <= 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