Exemplo n.º 1
0
        public void Test_Invalid_Remove_Prize_Level()
        {
            PrizeLevels pls = new PrizeLevels();

            pls.removePrizeLevel(5);

            Assert.IsTrue(pls.getNumPrizeLevels() == 0);
        }
Exemplo n.º 2
0
        public void Test_Invalid_Add_Prize_Level()
        {
            PrizeLevels pls = new PrizeLevels();

            pls.addPrizeLevel(null);

            Assert.IsTrue(pls.getNumPrizeLevels() == 0);
        }
Exemplo n.º 3
0
        public void Test_Invalid_Add_At_Prize_Level()
        {
            PrizeLevels pls = new PrizeLevels();
            PrizeLevel  pl1 = new PrizeLevel();

            pls.addPrizeLevelAt(null, 0);
            pls.addPrizeLevelAt(pl1, 40);

            Assert.IsTrue(pls.getNumPrizeLevels() == 0);
        }
Exemplo n.º 4
0
        public void Test_Remove_Count_Prize_Level()
        {
            PrizeLevels pls = new PrizeLevels();

            PrizeLevel pl1 = new PrizeLevel();

            pls.addPrizeLevel(pl1);

            pls.removePrizeLevel(0);

            Assert.IsTrue(pls.getNumPrizeLevels() == 0);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Gets complete combinations of near wins
        /// </summary>
        /// <param name="nearWinPrizeLevels">Number of near wins</param>
        /// <param name="totalNumberOfPicks">total number of picks for a level</param>
        /// <param name="prizeLevels">All prize levels</param>
        /// <returns></returns>
        private List<int[]> getPrizeLevelCombinationsForNearWins(
            int nearWinPrizeLevels,
            int totalNumberOfPicks,
            PrizeLevels.PrizeLevels prizeLevels)
        {
            int numberOfPrizeLevels = prizeLevels.getNumPrizeLevels();
            List<int[]> prizeLevelCombinations = new List<int[]>();
            int numberOfMaximumCombinations = prizeLevels.getNumPrizeLevels();

            List<int> prizeLevelsIndexes = new List<int>();
            for (int i = 0; i < numberOfPrizeLevels; i++)
            {
                prizeLevelsIndexes.Add(i);
            }
            // Max possible Base
            for (int i = 1; i <= nearWinPrizeLevels; i++)
            {
                for (int j = 0; j < numberOfMaximumCombinations; j++)
                {
                    Random rand = new Random();
                    int[] tempPrizeLevelCombinations = new int[i];
                    int numberOfPicksForPrizeLevelCombintation = 0;
                    bool newBaseComboAdded = false;
                    int failCount = 0;
                    List<int> tempPrizeLevelIndexes = new List<int>(prizeLevelsIndexes);
                    do
                    {
                        for (int k = 0; k < i; k++)
                        {
                            int randomPrizeLevelSelection = rand.Next(0, tempPrizeLevelIndexes.Count);
                            numberOfPicksForPrizeLevelCombintation += prizeLevels.getPrizeLevel(tempPrizeLevelIndexes[randomPrizeLevelSelection]).numCollections - 1;
                            tempPrizeLevelCombinations[k] = tempPrizeLevelIndexes[randomPrizeLevelSelection];
                            tempPrizeLevelIndexes.RemoveAt(randomPrizeLevelSelection);
                        }
                        if (!prizeLevelCombinations.Any(tempPrizeLevelCombinations.SequenceEqual) && numberOfPicksForPrizeLevelCombintation <= totalNumberOfPicks)
                        {
                            prizeLevelCombinations.Add(tempPrizeLevelCombinations);
                            newBaseComboAdded = true;
                        }
                        tempPrizeLevelCombinations = new int[i];
                        numberOfPicksForPrizeLevelCombintation = 0;
                        tempPrizeLevelIndexes = new List<int>(prizeLevelsIndexes);
                        failCount++;
                    } while (!newBaseComboAdded && failCount <= 2500);
                }
            }
            return prizeLevelCombinations;
        }
Exemplo n.º 6
0
 /// <summary>
 /// Gets all non winning picks for a given permutation
 /// </summary>
 /// <param name="permutation"> The base permutation</param>
 /// <param name="prizeLevels"> Used to find collection amount for unused pic<s/param>
 /// <returns> Returns an array of non winning picks</returns>
 private int[] getExtraPicks(
     int[] permutation,
     PrizeLevels.PrizeLevels prizeLevels)
 {
     List<int> usedIndexes = new List<int>();
     List<int> extraPicks = new List<int>();
     foreach (int i in permutation)
     {
         int j = Math.Abs(i);
         if (j - 1 != -1 && !usedIndexes.Contains((j - 1)))
         {
             usedIndexes.Add(j - 1);
         }
     }
     int numberOfPrizeLevels = prizeLevels.getNumPrizeLevels();
     for (int i = 0; i < numberOfPrizeLevels; i++)
     {
         if (!usedIndexes.Contains(i))
         {
             int numberOfCollections = prizeLevels.getPrizeLevel(i).numCollections - 1;
             for (int j = 0; j < numberOfCollections; j++)
             {
                 extraPicks.Add(i + 1);
             }
         }
     }
     return extraPicks.ToArray();
 }