summaryrefslogtreecommitdiff
path: root/DiscoBot/Auxiliary/RandomMisc.cs
diff options
context:
space:
mode:
Diffstat (limited to 'DiscoBot/Auxiliary/RandomMisc.cs')
-rw-r--r--DiscoBot/Auxiliary/RandomMisc.cs44
1 files changed, 14 insertions, 30 deletions
diff --git a/DiscoBot/Auxiliary/RandomMisc.cs b/DiscoBot/Auxiliary/RandomMisc.cs
index 7ba625e..205b3a7 100644
--- a/DiscoBot/Auxiliary/RandomMisc.cs
+++ b/DiscoBot/Auxiliary/RandomMisc.cs
@@ -1,52 +1,36 @@
-namespace DiscoBot.Auxiliary
-{
- using System;
- using System.Linq;
- using System.Text;
+using System;
+using System.Linq;
+using System.Text;
+namespace DiscoBot.Auxiliary
+{
public static class RandomMisc
{
- private static readonly Random Rand = new Random();
-
- // use: 4w6 +4
public static string Roll(string input)
{
var output = new StringBuilder();
var strings = input.Split('w', 'd').ToList();
- int count = Convert.ToInt32(strings[0]);
+ var count = Convert.ToInt32(strings[0]);
strings = strings[1].Split(' ').ToList();
- int d = Convert.ToInt32(strings[0]);
+ var d = Convert.ToInt32(strings[0]);
if (strings.Count > 0)
{
}
- int sum = 0;
- for (int i = 0; i < count; i++)
+ var sum = 0;
+ for (var i = 0; i < count; i++)
{
var roll = Dice.Roll(d);
sum += roll;
output.Append("[" + roll + "] ");
}
-
- if (strings.Count > 1)
- {
- sum += Convert.ToInt32(strings[1]);
- output.Append("sum: " + sum);
- }
- return output.ToString();
- }
+ if (strings.Count <= 1) return output.ToString();
+ sum += Convert.ToInt32(strings[1]);
+ output.Append("sum: " + sum);
- public static double Random(double stdDev = 1, double mean = 0)
- {
- double u1 = Rand.NextDouble(); // uniform(0,1) random doubles
- double u2 = Rand.NextDouble();
- double randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) *
- Math.Sin(2.0 * Math.PI * u2); // random normal(0,1)
- double randNormal =
- mean + stdDev * randStdNormal; // random normal(mean,stdDev^2)
- return randNormal;
+ return output.ToString();
}
}
-}
+} \ No newline at end of file