//4d6+8 would be: Utility.Dice( 4, 6, 8 ) public static int Dice(int numDice, int numSides, int bonus) { int total = 0; for (int i = 0; i < numDice; ++i) { total += RandomImpl.Next(numSides) + 1; } total += bonus; return(total); }
public static int Random(int from, int count) { if (count == 0) { return(from); } else if (count > 0) { return(from + RandomImpl.Next(count)); } else { return(from - RandomImpl.Next(-count)); } }
public static int RandomMinMax(int min, int max) { if (min > max) { int copy = min; min = max; max = copy; } else if (min == max) { return(min); } return(min + RandomImpl.Next((max - min) + 1)); }
public static double RandomDouble() { return(RandomImpl.NextDouble()); }
public static void RandomBytes(byte[] buffer) { RandomImpl.NextBytes(buffer); }
public static int Random(int count) { return(RandomImpl.Next(count)); }
public static bool RandomBool() { return(RandomImpl.NextBool()); }
public static int RandomList(params int[] list) { return(list[RandomImpl.Next(list.Length)]); }