示例#1
0
        //4d6+8 would be: Utility.Dice( 4, 6, 8 )
        public static int Dice(uint numDice, uint numSides, int bonus)
        {
            int  total = 0;
            uint sides = numSides;

            for (int i = 0; i < numDice; ++i)
            {
                total += (int)RandomImpl.Next(sides) + 1;
            }

            return(total + bonus);
        }
示例#2
0
        public static void Shuffle <T>(IList <T> list)
        {
            int count = list.Count;

            for (int i = count - 1; i > 0; i--)
            {
                int r    = (int)RandomImpl.Next((uint)count);
                T   swap = list[r];
                list[r] = list[i];
                list[i] = swap;
            }
        }
示例#3
0
        public static T[] Shuffle <T>(this T[] source, int index, int length)
        {
            T[]    sorted  = new T[source.Length];
            byte[] randoms = new byte[sorted.Length];

            source.CopyTo(sorted, 0);

            RandomImpl.NextBytes(randoms);
            Array.Sort(randoms, sorted, index, length);

            return(sorted);
        }
示例#4
0
        //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);
        }
示例#5
0
        public static bool PercentageBooleanGenerator(int chance)
        {
            int randomNo = RandomImpl.Next(101);

            if (randomNo <= chance)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#6
0
        public static int Random(int from, int count)
        {
            if (count == 0)
            {
                return(from);
            }

            if (count > 0)
            {
                return((int)(from + RandomImpl.Next((uint)count)));
            }

            return((int)(from - RandomImpl.Next((uint)-count)));
        }
示例#7
0
		public static int Random(int from, int count)
        {
            if (count == 0)
			{
				return from;
			}

            if (count > 0)
            {
                return from + RandomImpl.Next(count);
            }

            return from - RandomImpl.Next(-count);
        }
示例#8
0
        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));
        }
示例#9
0
文件: Utility.cs 项目: wwjwxb/ServUO
        public static double RandomMinMax(double min, double max)
        {
            if (min > max)
            {
                double copy = min;
                min = max;
                max = copy;
            }
            else if (min == max)
            {
                return(min);
            }

            return(min + (RandomImpl.NextDouble() * (max - min)));
        }
示例#10
0
 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));
     }
 }
示例#11
0
 public static int Random(uint count) => (int)RandomImpl.Next(count);
示例#12
0
 public static bool RandomBool()
 {
     return(RandomImpl.NextBool());
 }
示例#13
0
 public static int RandomList(params int[] list)
 {
     return(list[RandomImpl.Next(list.Length)]);
 }
示例#14
0
 public static object RandomList(ArrayList list)
 {
     return(list[RandomImpl.Next(list.Count)]);
 }
示例#15
0
文件: Utility.cs 项目: Brrm1/New-One
 public static T RandomList <T>(params T[] list)
 {
     return(list[RandomImpl.Next(list.Length)]);
 }
示例#16
0
 public static double RandomDouble() => RandomImpl.NextDouble();
示例#17
0
 public static T RandomList <T>(List <T> list)
 {
     return(list[RandomImpl.Next(list.Count)]);
 }
示例#18
0
 public static void RandomBytes(byte[] buffer)
 {
     RandomImpl.NextBytes(buffer);
 }
示例#19
0
 public static bool RandomBool() => RandomImpl.NextBool();
示例#20
0
 public static int Random(int count)
 {
     return(RandomImpl.Next(count));
 }
示例#21
0
 public static void RandomBytes(byte[] buffer) => RandomImpl.GetBytes(buffer);
示例#22
0
 public static double RandomDouble()
 {
     return(RandomImpl.NextDouble());
 }
示例#23
0
 public static void RandomBytes(Span <byte> buffer) => RandomImpl.GetBytes(buffer);