blob: f0f4def00c5fea60e6f3b704f8cacc985ca8b31b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
}
}
}
|