document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Security.Cryptography;
  6.  
  7. namespace AgainstMordridV1.Classes
  8. {
  9.     public class BaseRandom
  10.     {
  11.  
  12.         public static int GetRandomNumber(int iMin, int irRandValRange, RNGCryptoServiceProvider Gen)
  13.         {
  14.             if (Gen == null)
  15.                 Gen = new RNGCryptoServiceProvider();
  16.             if (irRandValRange == 0)
  17.                 irRandValRange = 1;
  18.  
  19.             byte[] randomNumber = new byte[4]; // 4 bytes per Int32
  20.             Gen.GetBytes(randomNumber);
  21.  
  22.             return BitConverter.ToInt32(randomNumber, 0) % irRandValRange + 1;
  23.         }
  24.  
  25.         public static int GetDiceRoll(int DNum)
  26.         {
  27.             return GetRandomNumber(1, DNum, null);
  28.         }
  29.  
  30.         public static int GetDiceRoll(int DNum, RNGCryptoServiceProvider Gen)
  31.         {
  32.             if (Gen == null)
  33.                 Gen = new RNGCryptoServiceProvider();
  34.             return GetRandomNumber(1, DNum, Gen);
  35.         }
  36.  
  37.         public static int GetMultiDiceRollsTotal(int DNum, int Rolls)
  38.         {
  39.             RNGCryptoServiceProvider Gen = new RNGCryptoServiceProvider();
  40.  
  41.             if (DNum * Rolls > Int32.MaxValue)
  42.             {
  43.                 throw new Exception("Dice params too Big");
  44.             }
  45.             int iCount = 0;
  46.             for (int i = 0; i < Rolls; i++)
  47.             {
  48.                 iCount += GetDiceRoll(DNum, Gen);
  49.             }
  50.             return iCount;
  51.         }
  52.  
  53.         public static int GetD6Successes(int Rolls)
  54.         {
  55.             RNGCryptoServiceProvider Gen = new RNGCryptoServiceProvider();
  56.  
  57.             if (6 * Rolls > Int32.MaxValue)
  58.             {
  59.                 throw new Exception("Dice params too Big");
  60.             }
  61.             int iCount = 0;
  62.             int iTemp = 0;
  63.             for (int i = 0; i < Rolls; i++)
  64.             {
  65.                 iTemp = GetDiceRoll(6, Gen);
  66.                 if (iTemp > 3)
  67.                     iCount++;
  68.                 if (iTemp == 6)
  69.                     i--;
  70.             }
  71.             return iCount;
  72.         }
  73.     }
  74. }
');