public void SetUpAllHandTests() { b = new BoneYard(12); b2 = new BoneYard(12); hand1 = new Hand(); hand2 = new Hand(b, 2); hand3 = new Hand(b, 6); hand4 = new Hand(); d11 = new Domino(1, 1); d12 = new Domino(1, 2); d23 = new Domino(2, 3); d55 = new Domino(5, 5); d33 = new Domino(3, 3); hand1.Add(d11); hand1.Add(d12); hand1.Add(d23); mt = new MexicanTrain(); mt.Add(d33); }
public void BoneyardTestDrawAndShuffle() { // Note - in future this will be more seprated to seperate tests. // Make a copy of the boneyard BoneYard beforeShuffle = boneyardOveridden; int beforeShuffleCount = boneyardOveridden.DominosRemaining; //shuffle it boneyardOveridden.Shuffle(); Assert.AreEqual(beforeShuffleCount, boneyardOveridden.DominosRemaining); // Test is empty + draw + is empty int max = this.boneyardOveridden.DominosRemaining; for (int i = 0; i < max; i++) { Assert.AreEqual(false, boneyardOveridden.IsEmpty()); Domino drawn = boneyardOveridden.Draw(); } Assert.AreEqual(0, boneyardOveridden.DominosRemaining); Assert.AreEqual(true, boneyardOveridden.IsEmpty()); }
static void TestboneyardDraw() { BoneYard b = new BoneYard(6); Domino d = b.Draw(); Console.WriteLine("Testing boneyard of dominos draw"); Console.WriteLine("dominosremaining. Expecting 27. \n" + b.DominosRemaining); Console.WriteLine("IsEmpty. Expecting false. " + b.IsEmpty); Console.WriteLine("Dealt Domino will be should be 0,0. " + d); // now let's deal them all and see what happens at the end for (int i = 1; i <= 27; i++) { d = b.Draw(); } Console.WriteLine("Dealt all 28 dominos"); Console.WriteLine("DominosRemaining. Expecting 0. " + b.DominosRemaining); Console.WriteLine("IsEmpty. Expecting true. " + b.IsEmpty); Console.WriteLine("Last domino should be 6,6. " + d); Console.WriteLine("Dealing again should return null. Expecting true. " + (b.Draw() == null)); Console.WriteLine(); }
private void SetUp() { // BoneYard this.pack = new BoneYard(9); // The TileSets in the current UI only go up to 9 //user Hand this.userHand = new Hand(this.pack, NUMBEROFPLAYERS); // 2 players this.computerHand = new Hand(this.pack, NUMBEROFPLAYERS); //Pictures this.userHandPBs = new List <PictureBox>(); this.mexicanTrainPBs = new List <PictureBox>(); this.userTrainPBs = new List <PictureBox>(); this.computerTrainPBs = new List <PictureBox>(); // Trains this.userTrain = new PrivateTrain(); this.computerTrain = new PrivateTrain(); this.mexicanTrain = new Train(); // Draw the initial PictureBoxes this.fillPictureBoxes(); // Create the Draggable Player Hand this.buildDraggable(); this.drawDraggable(); // Figure out who has the highest double this.playHighestDouble(); // Play that in the corner // Test from ME PC whosTurn = 1; }
public void InvalidConstructor() { Assert.Throws <ArgumentException>(() => invalidBoneYard = new BoneYard(-1)); Assert.Throws <ArgumentException>(() => invalidBoneYard = new BoneYard(100)); }
public void SetUpTests() { testBoneyard = new BoneYard(6); testBoneyard2 = new BoneYard(6); }
public void SetUpAllTests() { this.boneyard = new BoneYard(); this.boneyardOveridden = new BoneYard(8); // To Test with 8 Max Dots }
public void SetUpAllTesters() { boneyard = new BoneYard(4); boneyard2 = new BoneYard(6); boneyard3 = new BoneYard(12); }
private void RespondToEmpty(BoneYard by) { MessageBox.Show("The Boneyard must be empty"); }
public void SetUp() { PopulateTrainPBS(); Domino biggestdomino = null; EnableUserMove(); boneYard = new BoneYard(9); boneYard.Shuffle(); player = new Hand(boneYard); for (int i = 0; i < player.listOfDominos.Count(); i++) { PictureBox temp = CreateUserHandPB(i); pictureBoxes.Add(temp); LoadDomino(temp, player.listOfDominos[i]); } computer = new Hand(boneYard); int index; int caseSwitch = -1; Domino pldom = biggestDomino(player, out index); Domino comdom = biggestDomino(computer, out index); if (pldom == null && comdom == null) { caseSwitch = 1; } else if (pldom == null) { caseSwitch = 2; } else if (comdom == null) { caseSwitch = 3; } switch (caseSwitch) { case 1: biggestdomino = null; break; case 2: biggestdomino = comdom; computer.listOfDominos.Remove(biggestdomino); break; case 3: biggestdomino = pldom; //indexOfDominoInPlay = index; player.listOfDominos.Remove(biggestdomino); //RemovePBFromForm(pictureBoxes[index]); ReloadPBS(); break; default: if (pldom.Side1 > comdom.Side1) { biggestdomino = pldom; //indexOfDominoInPlay = index; player.listOfDominos.Remove(biggestdomino); //RemovePBFromForm(pictureBoxes[index]); ReloadPBS(); } else if (pldom.Side1 < comdom.Side1) { biggestdomino = comdom; computer.listOfDominos.Remove(biggestdomino); } else { biggestdomino = null; } break; } if (biggestdomino == null) { TearDown(); SetUp(); } else { maintrain = new MainTrain(biggestdomino.Side1); playerTrain = new PrivateTrain(player, biggestdomino.Side1); computerTrain = new PrivateTrain(computer, biggestdomino.Side1); LoadDomino(enginePB, biggestdomino); } EnableUserHandPBs(pictureBoxes); }
private static void TestMTPlay() { Console.WriteLine("Test MexicanTrain Play"); Console.WriteLine(); const int MAXDOTS = 6; Random rndGen = new Random(); int engVal = rndGen.Next(1, MAXDOTS + 1); // Test Train MexicanTrain test = new MexicanTrain(engVal); // Shuffled Boneyard BoneYard b = new BoneYard(MAXDOTS); b.Shuffle(); // Find Unplayable Hand h = new Hand(); Domino d; do { d = b.Draw(); } while (test.IsPlayable(h, d, out bool mustFlip)); Console.WriteLine("Test unplayable"); Console.WriteLine(); Console.WriteLine("Train playable value: " + test.PlayableValue.ToString()); Console.WriteLine("Drew unplayable: " + d.ToString()); Console.WriteLine("Train Before: " + test.ToString()); Console.WriteLine("Expect: Domino " + d.ToString() + " does not match last domino in the train and cannot be played."); string result = String.Empty; try { test.Play(h, d); } catch (Exception ex) { result = ex.Message; } Console.WriteLine("Result: " + result); Console.WriteLine("Train After: " + test.ToString()); Console.WriteLine(); //Find Playable do { d = b.Draw(); } while (!test.IsPlayable(h, d, out bool mustFlip)); Console.WriteLine("Test playable"); Console.WriteLine(); Console.WriteLine("Train playable value: " + test.PlayableValue.ToString()); Console.WriteLine("Drew playable: " + d.ToString()); Console.WriteLine("Train Before: " + test.ToString()); test.Play(h, d); Console.WriteLine("Train After: " + test.ToString()); }
private static void TestMTConstructorProperties() { Console.WriteLine("Test MexicanTrain constructor"); Console.WriteLine(); Random rndGen = new Random(); int engVal = rndGen.Next(1, 7); MexicanTrain test = new MexicanTrain(engVal); const int MAXDOTS = 6; BoneYard b = new BoneYard(MAXDOTS); b.Shuffle(); // IsEmpty (True) Console.WriteLine("Expect: IsEmpty True"); Console.WriteLine("Result: IsEmpty " + test.IsEmpty.ToString()); Console.WriteLine(); int handSize = rndGen.Next(1, 7); Domino last = new Domino(); for (int i = 0; i < handSize; i++) { Domino dom = b.Draw(); if (i == handSize - 1) { last = dom; } test.Add(dom); } // Dominos Drawn Console.WriteLine("Dominos: \n" + test.ToString()); // Count Console.WriteLine("Expect: Count " + handSize.ToString()); Console.WriteLine("Result: Count " + test.Count.ToString()); Console.WriteLine(); // EngineValue Console.WriteLine("Expect: Engine Value " + engVal.ToString()); Console.WriteLine("Result: Engine Value " + test.EngineValue.ToString()); Console.WriteLine(); // IsEmpty (False) Console.WriteLine("Expect: IsEmpty False"); Console.WriteLine("Result: IsEmpty " + test.IsEmpty.ToString()); Console.WriteLine(); // LastDomino Console.WriteLine("Expect: LastDomino is " + last.ToString()); Console.WriteLine("Result: LastDomino is " + test.LastDomino.ToString()); Console.WriteLine(); // PlayableValue Console.WriteLine("Expect: PlayableValue is " + last.Side2.ToString()); Console.WriteLine("Result: PlayableValue is " + test.PlayableValue.ToString()); Console.WriteLine(); // Index Console.WriteLine("Expect: last domino by index is " + last.ToString()); Console.WriteLine("Result: last domino by index is " + test[test.Count - 1].ToString()); Console.WriteLine(); }
public void SetUpAllTests() { def = new BoneYard(); overloaded = new BoneYard(13); }
public void SetUpAllTests() { boneYard = new BoneYard(2); boneYard2 = new BoneYard(2); boneYard3 = new BoneYard(12); }
public void SetUpAllTests() { empty = new Hand(); maxTwelve = new BoneYard(12); }
public PlayMTD() { InitializeComponent(); pack = new BoneYard(9); pack.Shuffle(); userHand = new Hand(pack, 2); computerHand = new Hand(pack, 2); int userHighest = userHand.IndexOfHighDouble(); int computerHighest = computerHand.IndexOfHighDouble(); // ToDo: what if one or both hands don't have a double? if (userHand[userHighest].Side1 > computerHand[computerHighest].Side1) { highestDoubleDomino = userHand[userHighest]; userHand.RemoveAt(userHighest); LoadDomino(enginePB, highestDoubleDomino); whosTurn = USER; } else { highestDoubleDomino = computerHand[computerHighest]; computerHand.RemoveAt(computerHighest); LoadDomino(enginePB, highestDoubleDomino); whosTurn = COMPUTER; } userTrain = new PlayerTrain(userHand, highestDoubleDomino.Side1); computerTrain = new PlayerTrain(computerHand, highestDoubleDomino.Side1); mexicanTrain = new MexicanTrain(highestDoubleDomino.Side1); // setup up - put all picture boxes in appropriate list of pbs // user hand userHandPBs = new List <PictureBox>(); for (int i = 0; i < userHand.Count; i++) { PictureBox pb = CreateUserHandPB(i); userHandPBs.Add(pb); } LoadHand(userHandPBs, userHand); // user train userTrainPBs = new List <PictureBox>(); userTrainPBs.Add(userTrainPB1); userTrainPBs.Add(userTrainPB2); userTrainPBs.Add(userTrainPB3); userTrainPBs.Add(userTrainPB4); userTrainPBs.Add(userTrainPB5); // computer train computerTrainPBs = new List <PictureBox>(); computerTrainPBs.Add(compTrainPB1); computerTrainPBs.Add(compTrainPB2); computerTrainPBs.Add(compTrainPB3); computerTrainPBs.Add(compTrainPB4); computerTrainPBs.Add(compTrainPB5); // mexican train mexicanTrainPBs = new List <PictureBox>(); mexicanTrainPBs.Add(mexTrainPB1); mexicanTrainPBs.Add(mexTrainPB2); mexicanTrainPBs.Add(mexTrainPB3); mexicanTrainPBs.Add(mexTrainPB4); mexicanTrainPBs.Add(mexTrainPB5); // both user and player trains are closed userTrainStatusLabel.Text = "Closed"; userTrainStatusLabel.ForeColor = Color.Red; computerTrainStatusLabel.Text = "Closed"; computerTrainStatusLabel.ForeColor = Color.Red; computerLabel.Text = "Crafty Computer's Train (" + computerHand.Count + ")"; // make last picture box in user's train and mexican train playable if (whosTurn == USER) { SetupTrainPB(userTrainPBs[0], true); SetupTrainPB(computerTrainPBs[0], false); SetupTrainPB(mexicanTrainPBs[0], true); EnableUserHandPBs(); drawButton.Enabled = true; passButton.Enabled = true; computerLabel.ForeColor = Color.Red; userLabel.ForeColor = Color.Green; } else { SetupTrainPB(userTrainPBs[0], false); SetupTrainPB(computerTrainPBs[0], false); SetupTrainPB(mexicanTrainPBs[0], false); drawButton.Enabled = false; passButton.Enabled = false; computerLabel.ForeColor = Color.Green; userLabel.ForeColor = Color.Red; CompleteComputerMove(); } }
// instantiate boneyard and hands // find the highest double in each hand // determine who should go first, remove the highest double from the appropriate hand // and display the highest double in the UI // instantiate trains now that you know the engine value // create all of the picture boxes for the user's hand and load the dominos for the hand // Add the picture boxes for each train to the appropriate list of picture boxes // update the labels on the UI // if it's the computer's turn, let her play // if it's the user's turn, enable the pbs so she can play public void SetUp() { pack = new BoneYard(9); pack.Shuffle(); userHand = new Hand(pack, 2); computerHand = new Hand(pack, 2); nextDrawIndex = userHand.Count; int userHighest = userHand.IndexOfHighDouble(); int computerHighest = computerHand.IndexOfHighDouble(); Domino highestDoubleDomino; // ToDo: what if neither has a double if ((userHighest != -1 && computerHighest == -1) || (userHand[userHighest].Side1 > computerHand[computerHighest].Side1)) { highestDoubleDomino = userHand[userHighest]; userHand.RemoveAt(userHighest); LoadDomino(enginePB, highestDoubleDomino); whosTurn = USER; } else { highestDoubleDomino = computerHand[computerHighest]; computerHand.RemoveAt(computerHighest); LoadDomino(enginePB, highestDoubleDomino); whosTurn = COMPUTER; } userTrain = new PlayerTrain(userHand, highestDoubleDomino.Side1); computerTrain = new PlayerTrain(computerHand, highestDoubleDomino.Side1); mexicanTrain = new MexicanTrain(highestDoubleDomino.Side1); // setup up - put all picture boxes in appropriate list of pbs // user hand userHandPBs = new List <PictureBox>(); for (int i = 0; i < userHand.Count; i++) { PictureBox pb = CreateUserHandPB(i); userHandPBs.Add(pb); } LoadHand(userHandPBs, userHand); // user train userTrainPBs = new List <PictureBox>(); userTrainPBs.Add(userTrainPB1); userTrainPBs.Add(userTrainPB2); userTrainPBs.Add(userTrainPB3); userTrainPBs.Add(userTrainPB4); userTrainPBs.Add(userTrainPB5); // computer train computerTrainPBs = new List <PictureBox>(); computerTrainPBs.Add(compTrainPB1); computerTrainPBs.Add(compTrainPB2); computerTrainPBs.Add(compTrainPB3); computerTrainPBs.Add(compTrainPB4); computerTrainPBs.Add(compTrainPB5); // mexican train mexicanTrainPBs = new List <PictureBox>(); mexicanTrainPBs.Add(mexTrainPB1); mexicanTrainPBs.Add(mexTrainPB2); mexicanTrainPBs.Add(mexTrainPB3); mexicanTrainPBs.Add(mexTrainPB4); mexicanTrainPBs.Add(mexTrainPB5); // both user and player trains are closed userTrainStatusLabel.Text = "Closed"; userTrainStatusLabel.ForeColor = Color.Red; computerTrainStatusLabel.Text = "Closed"; computerTrainStatusLabel.ForeColor = Color.Red; computerLabel.Text = "Crafty Computer's Train (" + computerHand.Count + ")"; // let the computer make a move if it's her turn if (whosTurn == COMPUTER) { CompleteComputerMove(); // now it's the user's turn - always } if (whosTurn == USER) { EnableUserMove(); } }
// instantiate boneyard and hands // find the highest double in each hand // determine who should go first, remove the highest double from the appropriate hand // and display the highest double in the UI // instantiate trains now that you know the engine value // create all of the picture boxes for the user's hand and load the dominos for the hand // Add the picture boxes for each train to the appropriate list of picture boxes // update the labels on the UI // if it's the computer's turn, let her play // if it's the user's turn, enable the pbs so she can play public void SetUp() { boneyard = new BoneYard(9); playersHand = new Hand(boneyard, 2); computersHand = new Hand(boneyard, 2); int pDIndex = playersHand.IndexOfHighDouble(); int cDIndex = computersHand.IndexOfHighDouble(); Domino highestDouble = null; bool playerGoesFirst = true; // player must have positive index value AND computer must either have negative index OR lower value on the domino, in order for player to go first. if (pDIndex >= 0 && (cDIndex == -1 || (playersHand[pDIndex].Side1 > computersHand[cDIndex].Side1))) { //player goes first highestDouble = playersHand[pDIndex]; playersHand.RemoveAt(pDIndex); LoadDomino(enginePB, highestDouble);//the highest double picture box } else if (cDIndex >= 0 && (pDIndex == -1 || (playersHand[pDIndex].Side1 < computersHand[cDIndex].Side1))) { playerGoesFirst = false; highestDouble = computersHand[cDIndex]; computersHand.RemoveAt(cDIndex); LoadDomino(enginePB, highestDouble); } playersTrain = new PlayerTrain(playersHand, highestDouble.Side1); computersTrain = new PlayerTrain(computersHand, highestDouble.Side1); mexicanTrain = new MexicanTrain(highestDouble.Side1); playersHandPbs = new List <PictureBox>(); for (int i = 0; i < playersHand.Count; i++) { playersHandPbs.Add(CreateUserHandPB(i)); } LoadHand(playersHandPbs, playersHand); computersTrainPbs = new List <PictureBox>(5); computersTrainPbs.Add(compTrainPB1); computersTrainPbs.Add(compTrainPB2); computersTrainPbs.Add(compTrainPB3); computersTrainPbs.Add(compTrainPB4); computersTrainPbs.Add(compTrainPB5); playersTrainPbs = new List <PictureBox>(5); playersTrainPbs.Add(userTrainPB1); playersTrainPbs.Add(userTrainPB2); playersTrainPbs.Add(userTrainPB3); playersTrainPbs.Add(userTrainPB4); playersTrainPbs.Add(userTrainPB5); mexicanTrainPbs = new List <PictureBox>(5); mexicanTrainPbs.Add(mexTrainPB1); mexicanTrainPbs.Add(mexTrainPB2); mexicanTrainPbs.Add(mexTrainPB3); mexicanTrainPbs.Add(mexTrainPB4); mexicanTrainPbs.Add(mexTrainPB5); UpdateTrainStatusLabels(); if (playerGoesFirst == true) { EnableUserHandPBs(); } else { CompleteComputerMove(); } }