public void TestGenerateGameplay()
        {
            PrizeLevels prizeLevels = createPrizeLevels();
            List<DivisionModel> divisions = new List<DivisionModel>();
            MainWindowModel.Instance.DivisionsModel = new DivisionsModel();

            DivisionModel div1 = new DivisionModel();
            div1.DivisionNumber = 1;
            div1.addPrizeLevel(prizeLevels.getPrizeLevel(0));
            divisions.Add(div1);

            DivisionModel div2 = new DivisionModel();
            div2.DivisionNumber = 2;
            div2.addPrizeLevel(prizeLevels.getPrizeLevel(1));
            divisions.Add(div2);

            //DivisionModel div3 = new DivisionModel();
            //div3.DivisionNumber = 3;
            //div3.addPrizeLevel(prizeLevels.getPrizeLevel(3));
            //divisions.Add(div3);

            //DivisionModel div4 = new DivisionModel();
            //div4.DivisionNumber = 4;
            //div4.addPrizeLevel(prizeLevels.getPrizeLevel(4));
            //divisions.Add(div4);

            ITile board = createBoard(prizeLevels);
            List<ITile> boards = new List<ITile>();
            boards.Add(board);
            GamePlayGeneration gp = new GamePlayGeneration(boards);
            gp.Generate(3, divisions, prizeLevels.prizeLevels, 1);
            string output = gp.GetFormattedGameplay(boards);
        }
 public void testGetNumberOfDivisions()
 {
     DivisionsModel dm = new DivisionsModel();
     for (int i = 0; i < numberOfTestRuns; i++)
     {
         DivisionModel div = new DivisionModel();
         dm.addDivision(div);
         Assert.IsTrue(dm.getNumberOfDivisions() == i +1, "Number of divisions is wrong.");
     }
 }
 public void testAddPirzeLevel()
 {
     DivisionModel dm = new DivisionModel();
     for (int i = 0; i < testAmount; i++)
     {
         PrizeLevel pl = new PrizeLevel();
         pl.prizeValue = 100 + i;
         dm.addPrizeLevel(pl);
         Assert.IsTrue(dm.getPrizeLevel(i) != null, "PrizeLevel not added to Division.");
         Assert.IsTrue(dm.getPrizeLevel(i).prizeValue == 100 + i, "PrizeLevel not correct value.");
     }
 }
 public void testGetDivisionValue()
 {
     DivisionModel dm = new DivisionModel();
     double prizeLevel = 0.0f;
     for (int i = 0; i < testAmount; i++)
     {
         PrizeLevel pl = new PrizeLevel();
         pl.prizeValue = 100 + i;
         prizeLevel += pl.prizeValue;
         dm.addPrizeLevel(pl);
         Assert.IsTrue(dm.getPrizeLevel(i) != null, "PrizeLevel not added to Division.");
         Assert.IsTrue(dm.calculateDivisionValue() == prizeLevel, "PrizeLevel not correct value.");
     }
 }
Exemple #5
0
        public DivisionUC(PrizeLevels.PrizeLevels initialPrizeLevels, int number)
        {
            InitializeComponent();
            DivModel = new DivisionModel();
            setDataContextToModel();
            Prizes = initialPrizeLevels;
            DivModel.DivisionNumber = number;

            for (int i = 0; i < DivisionModel.MAX_PRIZE_BOXES; i++)
            {
                LevelBox levelBox = new LevelBox(i + 1);
                DivModel.levelBoxes.Add(levelBox);
                PrizeLevelBox box = new PrizeLevelBox(this, DivModel.levelBoxes[i]);
                if (i < initialPrizeLevels.getNumPrizeLevels()) box.levelModel.IsAvailable = true;
                prizeLevelsGrid.Children.Add(box);
            }
        }
 /// <summary>
 /// Validates that each division's total player picks is less than or equal to the set number of player picks
 /// </summary>
 private void checkDivisionsPicks()
 {
     for (int index = 0; index < divisionsHolderPanel.Children.Count; index++)
     {
         DivisionModel currentDivision = ((DivisionUC)divisionsHolderPanel.Children[index]).DivModel;
         if (currentDivision.TotalPlayerPicks <= GameSetupUC.pickCheck)
         {
             ErrorService.Instance.resolveError("010", null, currentDivision.errorID);
         }
         else
         {
             currentDivision.errorID = ErrorService.Instance.reportError("010", new List <string> {
                 currentDivision.DivisionNumber.ToString()
             }, currentDivision.errorID);
         }
     }
 }
Exemple #7
0
        public DivisionUC(PrizeLevels.PrizeLevels initialPrizeLevels, int number)
        {
            InitializeComponent();
            DivModel = new DivisionModel();
            setDataContextToModel();
            Prizes = initialPrizeLevels;
            DivModel.DivisionNumber = number;

            for (int i = 0; i < DivisionModel.MAX_PRIZE_BOXES; i++)
            {
                LevelBox levelBox = new LevelBox(i + 1);
                DivModel.levelBoxes.Add(levelBox);
                PrizeLevelBox box = new PrizeLevelBox(this, DivModel.levelBoxes[i]);
                if (i < initialPrizeLevels.getNumPrizeLevels())
                {
                    box.levelModel.IsAvailable = true;
                }
                prizeLevelsGrid.Children.Add(box);
            }
        }
Exemple #8
0
 public void addDivision(DivisionModel newDivision)
 {
     divisions.Add(newDivision);
     divisions.Sort();
 }
Exemple #9
0
 public void addDivision(DivisionModel newDivision)
 {
     divisions.Add(newDivision);
 }
Exemple #10
0
 public void removeDivision(DivisionModel divisionToRemove)
 {
     divisions.Remove(divisionToRemove);
 }
        public void testBuildGameDataFiveDivisionsNinePicks()
        {
            GameSetupModel gs = new GameSetupModel();
            gs.totalPicks = 9;

            PrizeLevel pl1 = new PrizeLevel();
            pl1.isInstantWin = false;
            pl1.numCollections = 5;
            pl1.prizeValue = 100;

            PrizeLevel pl2 = new PrizeLevel();
            pl2.isInstantWin = false;
            pl2.numCollections = 4;
            pl2.prizeValue = 50;

            PrizeLevel pl3 = new PrizeLevel();
            pl3.isInstantWin = false;
            pl3.numCollections = 4;
            pl3.prizeValue = 25;

            PrizeLevel pl4 = new PrizeLevel();
            pl4.isInstantWin = false;
            pl4.numCollections = 3;
            pl4.prizeValue = 10;

            PrizeLevel pl5 = new PrizeLevel();
            pl5.isInstantWin = false;
            pl5.numCollections = 3;
            pl5.prizeValue = 5;

            PrizeLevels pls = new PrizeLevels();
            pls.addPrizeLevel(pl1);
            pls.addPrizeLevel(pl2);
            pls.addPrizeLevel(pl3);
            pls.addPrizeLevel(pl4);
            pls.addPrizeLevel(pl5);

            DivisionModel dm1 = new DivisionModel();
            dm1.addPrizeLevel(pl1);
            dm1.MaxPermutations = 1000;

            DivisionModel dm2 = new DivisionModel();
            dm2.addPrizeLevel(pl1);
            dm2.addPrizeLevel(pl2);
            dm2.MaxPermutations = 1000;

            DivisionModel dm3 = new DivisionModel();
            dm3.addPrizeLevel(pl1);
            dm3.addPrizeLevel(pl3);
            dm3.MaxPermutations = 1000;

            DivisionModel dm4 = new DivisionModel();
            dm4.addPrizeLevel(pl2);
            dm4.addPrizeLevel(pl3);
            dm4.MaxPermutations = 1000;

            DivisionModel dm5 = new DivisionModel();
            dm5.addPrizeLevel(pl4);
            dm5.addPrizeLevel(pl5);
            dm5.MaxPermutations = 1000;

            DivisionsModel dms = new DivisionsModel();
            dms.addDivision(dm1);
            dms.addDivision(dm2);
            dms.addDivision(dm3);
            dms.addDivision(dm4);
            dms.addDivision(dm5);
            dms.LossMaxPermutations = 1000;

            FileGenerationService fgs = new FileGenerationService();
            fgs.buildGameData(dms, pls, gs, "testBuildGameDataFiveDivisionsNinePicks");
        }
 public void testGetPrizeLevelsAtDivision()
 {
     DivisionModel dm = new DivisionModel();
     for (int i = 0; i < testAmount; i++)
     {
         PrizeLevel pl = new PrizeLevel();
         pl.prizeValue = 100.0f + i;
         dm.addPrizeLevel(pl);
         Assert.IsTrue(dm.getPrizeLevelsAtDivision().Count == i + 1, "incorrect amount of prizes");
     }
 }
 public void testGetSetPermutations()
 {
     DivisionModel dm = new DivisionModel();
     dm.MaxPermutations = 5000;
     Assert.IsTrue(dm.MaxPermutations == 5000);
 }
Exemple #14
0
        public int CompareTo(object obj)
        {
            DivisionModel dm = (DivisionModel)obj;

            return((int)Math.Ceiling(dm.calculateDivisionValue() - this.calculateDivisionValue()));
        }
        public void testBuildGameDataThreeDivisonsFourPicksWithLoss()
        {
            //Custom input for a game
            GameSetupModel gs = new GameSetupModel();
            gs.totalPicks = 4;

            PrizeLevel pl1 = new PrizeLevel();
            pl1.isInstantWin = false;
            pl1.numCollections = 3;
            pl1.prizeValue = 100;

            PrizeLevel pl2 = new PrizeLevel();
            pl2.isInstantWin = false;
            pl2.numCollections = 2;
            pl2.prizeValue = 50;

            PrizeLevel pl3 = new PrizeLevel();
            pl3.isInstantWin = false;
            pl3.numCollections = 2;
            pl3.prizeValue = 25;

            PrizeLevels pls = new PrizeLevels();
            pls.addPrizeLevel(pl1);
            pls.addPrizeLevel(pl2);
            pls.addPrizeLevel(pl3);

            DivisionModel dm1 = new DivisionModel();
            dm1.addPrizeLevel(pl1);
            dm1.MaxPermutations = 1000;

            DivisionModel dm2 = new DivisionModel();
            dm2.addPrizeLevel(pl2);
            dm2.MaxPermutations = 1000;

            DivisionModel dm3 = new DivisionModel();
            dm3.addPrizeLevel(pl2);
            dm3.addPrizeLevel(pl3);
            dm3.MaxPermutations = 1000;

            DivisionModel dm4 = new DivisionModel();
            dm4.MaxPermutations = 1000;

            DivisionsModel dms = new DivisionsModel();
            dms.addDivision(dm1);
            dms.addDivision(dm2);
            dms.addDivision(dm3);
            dms.addDivision(dm4);
            dms.LossMaxPermutations = 1000;

            //File Generator
            FileGenerationService fgs = new FileGenerationService();
            fgs.buildGameData(dms, pls, gs, "testBuildGameDataThreeDivisonsFourPicksWithLoss");
        }
Exemple #16
0
 public void removeDivision(DivisionModel divisionToRemove)
 {
     divisions.Remove(divisionToRemove);
 }
        /// <summary>
        /// Validates each division
        ///     -Determines if the division is empty (has no selected prize levels)
        ///     -Validates a division's uniqueness from other divisions
        ///     -Validates whether a division's total collections is less than the total picks set
        ///     -Validates whether or not a division can have an instant win prize level
        /// </summary>
        public void validateDivision()
        {
            checkDivisionsPicks();

            for (int index = 0; index < divisionsHolderPanel.Children.Count; index++)
            {
                DivisionModel divToCompare = ((DivisionUC)divisionsHolderPanel.Children[index]).DivModel;
                bool          empty        = true;
                for (int i = 0; i < DivisionModel.MAX_PRIZE_BOXES && empty; i++)
                {
                    if (divToCompare.levelBoxes[i].IsSelected)
                    {
                        empty = false;
                    }
                }

                if (!empty)
                {
                    ErrorService.Instance.resolveWarning("005", new List <string> {
                        divToCompare.DivisionNumber.ToString()
                    }, divToCompare.errorID);
                    bool valid = true;
                    for (int i = 0; i < divisionsHolderPanel.Children.Count && valid; i++)
                    {
                        DivisionModel currentDiv = ((DivisionUC)divisionsHolderPanel.Children[i]).DivModel;
                        if (divToCompare.DivisionNumber != currentDiv.DivisionNumber)
                        {
                            bool isUnique = false;
                            for (int prizeIndex = 0; prizeIndex < prizes.getNumPrizeLevels() && !isUnique; prizeIndex++)
                            {
                                if (divToCompare.levelBoxes[prizeIndex].IsSelected != currentDiv.levelBoxes[prizeIndex].IsSelected)
                                {
                                    isUnique = true;
                                }
                            }

                            if (!isUnique)
                            {
                                divToCompare.errorID = ErrorService.Instance.reportError("009", new List <string> {
                                    divToCompare.DivisionNumber.ToString()
                                }, divToCompare.errorID);

                                valid = false;
                            }
                        }
                    }

                    if (valid)
                    {
                        ErrorService.Instance.resolveError("009", null, divToCompare.errorID);
                    }
                }
                else
                {
                    ErrorService.Instance.resolveError("009", null, divToCompare.errorID);
                    divToCompare.errorID = ErrorService.Instance.reportWarning("005", new List <string> {
                        divToCompare.DivisionNumber.ToString()
                    }, divToCompare.errorID);
                }

                int maxCollections = 0;
                for (int i = 0; i < divToCompare.getPrizeLevelsAtDivision().Count; i++)
                {
                    if (divToCompare.getPrizeLevel(i).isInstantWin)
                    {
                        maxCollections += 1;
                    }
                    else
                    {
                        maxCollections += divToCompare.getPrizeLevel(i).numCollections;
                    }
                }
                maxCollections -= GameSetupUC.pickCheck;
                for (int i = 0; i < prizes.getNumPrizeLevels(); i++)
                {
                    if (!divToCompare.getPrizeLevelsAtDivision().Contains(prizes.getPrizeLevel(i)))
                    {
                        maxCollections -= (prizes.getPrizeLevel(i).numCollections - 1);
                    }
                }


                if (0 < maxCollections)
                {
                    divToCompare.errorID = ErrorService.Instance.reportError("011", new List <string> {
                        divToCompare.DivisionNumber.ToString()
                    }, divToCompare.errorID);
                }
                else
                {
                    ErrorService.Instance.resolveError("011", null, divToCompare.errorID);
                }

                //Check if a Division can have an Instant Win
                int minimumCollections = GameSetupUC.pickCheck;
                for (int i = 0; i < divToCompare.getPrizeLevelsAtDivision().Count; i++)
                {
                    if (divToCompare.getPrizeLevel(i).isInstantWin)
                    {
                        minimumCollections -= 1;
                    }
                    else
                    {
                        minimumCollections -= divToCompare.getPrizeLevel(i).numCollections;
                    }
                }
                for (int i = 0; i < prizes.getNumPrizeLevels(); i++)
                {
                    if (!divToCompare.getPrizeLevelsAtDivision().Contains(prizes.getPrizeLevel(i)))
                    {
                        minimumCollections -= prizes.getPrizeLevel(i).numCollections - 1;
                    }
                }
                if (minimumCollections > 0)
                {
                    divToCompare.errorID = ErrorService.Instance.reportWarning("007", new List <string> {
                        divToCompare.DivisionNumber.ToString()
                    }, divToCompare.errorID);
                }
                else
                {
                    ErrorService.Instance.resolveWarning("007", null, divToCompare.errorID);
                }
            }

            int allCollections = 0;

            for (int i = 0; i < prizes.getNumPrizeLevels(); i++)
            {
                allCollections += prizes.getPrizeLevel(i).numCollections - 1;
            }

            if (GameSetupUC.pickCheck > allCollections)
            {
                dpucID = ErrorService.Instance.reportError("012", new List <string> {
                }, dpucID);
            }
            else
            {
                ErrorService.Instance.resolveError("012", null, dpucID);
            }
        }
        /// <summary>
        /// Loads in an existing division into the divisions section. If the max of 30 is met, nothing is added and the add buttom is disabled
        /// </summary>
        /// <param name="div">The existing division</param>
        public void loadInDivision(DivisionModel div)
        {
            if (MainWindowModel.Instance.DivisionsModel.getSize() <= MAX_DIVISIONS)
            {
                int divNumber = divisionsHolderPanel.Children.Count + 1;
                DivisionUC division = new DivisionUC(prizes, divNumber);
                division.DivModel = div;
                division.setDataContextToModel();
                division.DivModel.DivisionNumber = divNumber;
                division.DivModel.levelBoxes = div.levelBoxes;
                division.Margin = new Thickness(marginAmount, marginAmount, 0, 0);
                division.SectionContainer = this;

                division.setupLoadedDivision();
                division.updateDivision();

                divisionsHolderPanel.Children.Add(division);
                this.AddListener(division);
                validateDivision();
            }

            if (MainWindowModel.Instance.DivisionsModel.getSize() >= MAX_DIVISIONS)
            {
                addDivisionButton.IsEnabled = false;
                addDivisionButton.Opacity = 0.3;
            }

            divisionCounterLabel.Content = divisionsHolderPanel.Children.Count;
            isSectionEmpty();
        }
        public void testBuildGameDataMaxDivison()
        {
            GameSetupModel gs = new GameSetupModel();
            gs.totalPicks = 20;

            int numPrizeLevels = 12;
            PrizeLevel[] prizes = new PrizeLevel[numPrizeLevels];
            PrizeLevels pls = new PrizeLevels();
            for (int i = 0; i < numPrizeLevels; i++)
            {
                prizes[i] = new PrizeLevel();
                prizes[i].isInstantWin = false;
                prizes[i].numCollections = i + 1;
                prizes[i].prizeValue = 100 * i;
                pls.addPrizeLevel(prizes[i]);
            }

            int numberOfDivions = 30;
            DivisionModel[] divisions = new DivisionModel[numberOfDivions];
            DivisionsModel dms = new DivisionsModel();
            dms.LossMaxPermutations = 30000;
            Random rand = new Random();
            for (int i = 0; i < numberOfDivions; i++)
            {
                divisions[i] = new DivisionModel();
                divisions[i].addPrizeLevel(prizes[rand.Next(0, 12)]);
                divisions[i].MaxPermutations = 30000;
                dms.addDivision(divisions[i]);
            }

            FileGenerationService fgs = new FileGenerationService();
            fgs.buildGameData(dms, pls, gs, "MaxTest");
        }