private PrizeLevels createPrizeLevels() { PrizeLevels prizes = new PrizeLevels(); PrizeLevel A1 = new PrizeLevel(); A1.numCollections = 1; A1.prizeLevel = 0; A1.isBonusGame = true; prizes.addPrizeLevel(A1); PrizeLevel A2 = new PrizeLevel(); A2.numCollections = 1; A2.prizeLevel = 1; prizes.addPrizeLevel(A2); //PrizeLevel A3 = new PrizeLevel(); //A3.numCollections = 3; //A3.prizeLevel = 3; //A3.isInstantWin = true; //prizes.addPrizeLevel(A3); //PrizeLevel A4 = new PrizeLevel(); //A4.numCollections = 3; //A4.prizeLevel = 4; //prizes.addPrizeLevel(A4); return prizes; }
/// <summary> /// Adds a new PrizeLevel at the index provided /// </summary> /// <param name="obj">The PrizeLevel being added</param> /// <param name="index">Where the new PrizeLevel will be placed</param> public void addPrizeLevelAt(PrizeLevel obj, int index) { if (!(index >= prizeLevels.Count || index < 0) && obj!=null) prizeLevels.Insert(index, obj); numPrizeLevels = prizeLevels.Count; }
public void addPrizeLevel(PrizeLevel obj) { if(obj!=null) prizeLevels.Add(obj); numPrizeLevels = prizeLevels.Count; }
/// <summary> /// Adds a new prize level /// </summary> /// <param name="obj">The PrizeLevel to be added</param> public void addPrizeLevel(PrizeLevel obj) { if(obj!=null) prizeLevels.Add(obj); numPrizeLevels = prizeLevels.Count; calculateTotalCollections(); }
public void Test_Prize_Comparison_Null() { PrizeLevel pl1 = new PrizeLevel(); pl1.prizeValue = 100; Assert.IsTrue(pl1.CompareTo(null) > 0); }
public void Test_Prize_Value_Assignment() { PrizeLevel pl1 = new PrizeLevel(); pl1.prizeValue = 100; Assert.IsTrue(pl1.prizeValue == 100); }
public void Test_Prize_Win_Assignment() { PrizeLevel pl1 = new PrizeLevel(); pl1.isInstantWin = true; Assert.IsTrue(pl1.isInstantWin); }
public void Test_Prize_Level_Assignment() { PrizeLevel pl1 = new PrizeLevel(); pl1.prizeLevel = 10; Assert.IsTrue(pl1.prizeLevel == 10); }
public void Test_Prize_Collection_Assignment() { PrizeLevel pl1 = new PrizeLevel(); pl1.numCollections = 5; Assert.IsTrue(pl1.numCollections == 5); }
public void addPrizeLevel(PrizeLevel obj) { if (obj != null) { prizeLevels.Add(obj); } numPrizeLevels = prizeLevels.Count; }
public void addPrizeLevelAt(PrizeLevel obj, int index) { if (!(index >= prizeLevels.Count || index < 0) && obj != null) { prizeLevels.Insert(index, obj); } numPrizeLevels = prizeLevels.Count; }
public void Test_Invalid_Level_Prize_Level() { PrizeLevels pls = new PrizeLevels(); PrizeLevel pl1 = new PrizeLevel(); pls.addPrizeLevel(pl1); Assert.IsTrue(pls.getLevelOfPrize(null) == -1); }
public void Test_Prize_Comparison() { PrizeLevel pl1 = new PrizeLevel(); PrizeLevel pl2 = new PrizeLevel(); pl1.prizeValue = 50; pl2.prizeValue = 100; Assert.IsTrue(pl1.CompareTo(pl2) > 0); }
public void Test_Add_Get_Prize_Level() { PrizeLevels pls = new PrizeLevels(); PrizeLevel pl1 = new PrizeLevel(); pls.addPrizeLevel(pl1); Assert.IsTrue(pl1.Equals(pls.getPrizeLevel(0))); }
public int CompareTo(object obj) { if (obj == null) { return(1); } PrizeLevel pl = (PrizeLevel)obj; return((int)Math.Ceiling(pl.prizeValue - this.prizeValue)); }
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); }
/// <summary> /// Get the index of the PrizeLevel being passed in /// </summary> /// <param name="obj">The PrizeLevel that you want to know the index of</param> /// <returns>The index of the desired PrizeLevel</returns> public int getLevelOfPrize(PrizeLevel obj) { for (int i = 0; i < prizeLevels.Count; i++) { if (prizeLevels[i].Equals(obj)) return i; } return -1; }
public void Test_Add_At_Prize_Level() { PrizeLevels pls = new PrizeLevels(); PrizeLevel pl1 = new PrizeLevel(); PrizeLevel pl2 = new PrizeLevel(); pls.addPrizeLevel(pl1); pls.addPrizeLevelAt(pl2, 0); Assert.IsTrue(pls.getLevelOfPrize(pl2) == 0); }
public UserControlPrizeLevel() { InitializeComponent(); //Sets up the model object and the data context for the binding in the xaml plObject = new PrizeLevel(); setDataContext(); plObject.isInstantWin = false; plObject.numCollections = 2; plObject.prizeValue = 0; this.Loaded += new RoutedEventHandler(MainView_Loaded); }
/// <summary> /// Default constructor for PrizeLevel GUI /// </summary> public UserControlPrizeLevel() { InitializeComponent(); //Sets up the model object and the data context for the binding in the xaml plObject = new PrizeLevel(); setDataContext(); plObject.isInstantWin = false; plObject.numCollections = 1; plObject.prizeValue = 0; this.Loaded += new RoutedEventHandler(MainView_Loaded); }
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 int getLevelOfPrize(PrizeLevel obj) { for (int i = 0; i < prizeLevels.Count; i++) { if (prizeLevels[i].Equals(obj)) { return(i); } } return(-1); }
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."); } }
public void loadExistingPrizeLevel(PrizeLevel loadedPrizeLevel) { UserControlPrizeLevel ucpl = new UserControlPrizeLevel(); ucpl.OuterGrid.Margin = new Thickness(0, Prizes.Children.Count * MARGIN, 0, 0); ucpl.addListener(this); Prizes.Children.Add(ucpl); ucpl.plObject = loadedPrizeLevel; ucpl.plObject.initializeListener(); ucpl.setDataContext(); ucpl.plObject.prizeLevel = Prizes.Children.Count; prizeLevelCounterLabel.Content = Prizes.Children.Count; if (Prizes.Children.Count >= 12) { AddButton.IsEnabled = false; AddButton.Opacity = 0.3; } }
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"); }
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"); }
/// <summary> /// Adds a PrizeLevel to the Division /// </summary> /// <param name="prizeLevelToAdd">The PrizeLevel that is being added to the Division</param> public void addPrizeLevel(PrizeLevel prizeLevelToAdd) { selectedPrizes.Add(prizeLevelToAdd); }
/// <summary> /// Removes a PrizeLevel from the Division /// </summary> /// <param name="prizeLevelToRemove">The PrizeLevel being removed from the Division</param> public void removePrizeLevel(PrizeLevel prizeLevelToRemove) { selectedPrizes.Remove(prizeLevelToRemove); }
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); }
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"); }
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"); } }
/// <summary> /// Attach data from loadedPrizeLevel to prize level /// </summary> /// <param name="loadedPrizeLevel">Prize Level from the loaded project</param> public void loadExistingPrizeLevel(PrizeLevel loadedPrizeLevel) { UserControlPrizeLevel ucpl = new UserControlPrizeLevel(); ucpl.OuterGrid.Margin = new Thickness(0, Prizes.Children.Count * MARGIN, 0, 0); ucpl.AddListener(this); Prizes.Children.Add(ucpl); ucpl.plObject = loadedPrizeLevel; ucpl.plObject.initializeListener(); ucpl.setDataContext(); ucpl.plObject.prizeLevel = Prizes.Children.Count; prizeLevelCounterLabel.Content = Prizes.Children.Count; }
public void personalGenBoardTest() { BoardGeneration bg = new BoardGeneration(); int boardSize = 26; int initialReachable = 20; PrizeLevels prizes = new PrizeLevels(); PrizeLevel A1 = new PrizeLevel(); A1.numCollections = 3; A1.prizeLevel = 1; A1.isBonusGame = true; prizes.addPrizeLevel(A1); PrizeLevel A2 = new PrizeLevel(); A2.numCollections = 3; A2.prizeLevel = 2; prizes.addPrizeLevel(A2); PrizeLevel A3 = new PrizeLevel(); A3.numCollections = 3; A3.prizeLevel = 3; A3.isInstantWin = true; prizes.addPrizeLevel(A3); PrizeLevel A4 = new PrizeLevel(); A4.numCollections = 3; A4.prizeLevel = 4; prizes.addPrizeLevel(A4); int numberOfExpectedCollection = 12; int numberOfExpectedMoveBack = 3; int numberOfExpectedMoveForward = 2; ITile firstTile = bg.GenerateBoard(boardSize, initialReachable, 2, 6, numberOfExpectedMoveBack, numberOfExpectedMoveForward, prizes, 1, 2); int numberOfCollection = 0; int numberOfMoveBack = 0; int numberOfMoveForward = 0; int numberOfextraGames = 0; int numberOfTiles = 0; ITile currentTile = firstTile; while (currentTile != null) { if (currentTile.Type == TileTypes.collection) { numberOfCollection++; } else if (currentTile.Type == TileTypes.moveForward) { numberOfMoveForward++; } else if (currentTile.Type == TileTypes.moveBack) { numberOfMoveBack++; } else if (currentTile.Type == TileTypes.extraGame) { numberOfextraGames++; } numberOfTiles++; currentTile = currentTile.Child; } string board = bg.ToString(); Assert.IsTrue(numberOfCollection == numberOfExpectedCollection, "Number Of Collection Tiles not correct"); Assert.IsTrue(numberOfMoveBack == numberOfExpectedMoveBack, "Number Of MoveBack Tiles not correct"); Assert.IsTrue(numberOfMoveForward == numberOfExpectedMoveForward, "Number Of MoveForward Tiles not correct"); Assert.IsTrue(boardSize == numberOfTiles, "Number Of Tiles not correct"); if (board == "") { } }