Пример #1
0
 /// <summary>
 /// Builds the file To Generate Game Data
 /// </summary>
 /// <param name="divisions">All Division information</param>
 /// <param name="prizeLevels">All Prize Level information</param>
 /// <param name="gameInfo">All game Inforamtion</param>
 /// <param name="fileName">The full output file name and pat</param>
 /// <param name="gameSetupUC"></param>
 public void buildGameData(
     Divisions.DivisionsModel divisions,
     PrizeLevels.PrizeLevels prizeLevels,
     GameSetup.GameSetupModel gameInfo,
     string fileName,
     GameSetup.GameSetupUC gameSetupUC)
 {
     addListener(gameSetupUC);
     int numberOfDivisions = divisions.getNumberOfDivisions() + 1;
     List<int[]>[] divisionLevels = new List<int[]>[numberOfDivisions];
     List<Thread> threads = new List<Thread>();
     for (int i = 0; i < numberOfDivisions; i++)
     {
         int divisionIndex = i;
         Thread t;
         if (divisionIndex == numberOfDivisions - 1)
         {
             t = new Thread(() => divisionLevels[divisionIndex] = getDivisionLossingPermutations(gameInfo, prizeLevels, divisions).OrderBy(a => Guid.NewGuid()).ToList());
         }
         else
         {
             int temp = i;
             t = new Thread(() => divisionLevels[divisionIndex] = getDivisionWinningPermutations(divisionIndex, gameInfo.totalPicks, divisions.getDivision(temp).MaxPermutations, divisions.getDivision(divisionIndex), prizeLevels).OrderBy(a => Guid.NewGuid()).ToList());
         }
         t.Start();
         threads.Add(t);
     }
     for (int i = 0; i < threads.Count; i++)
     {
         threads.ElementAt(i).Join();
     }
     writeFile(fileName, divisionLevels, buildHeader(prizeLevels, divisions));
     shout("FileFinished");
 }