summaryrefslogtreecommitdiff
path: root/dsa/DiscoBot/Auxiliary/Dice.cs
diff options
context:
space:
mode:
authorDennis Kobert <d-kobert@web.de>2019-06-11 23:38:13 +0200
committerDennis Kobert <d-kobert@web.de>2019-06-11 23:38:13 +0200
commit2fa4a0e50ebfc97059c8b84dbd17e79f9afc8a8d (patch)
treec3b34ccb2737e347a73768536895cbbaab13cc01 /dsa/DiscoBot/Auxiliary/Dice.cs
parentec991104f56e90d7bb2878da2fe6ed4e585dfc46 (diff)
parentaf74efccf8d21e6151022b71f3cacd3fa83024ee (diff)
Merge branch 'rework-backend'
Diffstat (limited to 'dsa/DiscoBot/Auxiliary/Dice.cs')
-rw-r--r--dsa/DiscoBot/Auxiliary/Dice.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/dsa/DiscoBot/Auxiliary/Dice.cs b/dsa/DiscoBot/Auxiliary/Dice.cs
new file mode 100644
index 0000000..f0f4def
--- /dev/null
+++ b/dsa/DiscoBot/Auxiliary/Dice.cs
@@ -0,0 +1,31 @@
+using System;
+
+namespace DiscoBot.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