public void TestIsPlayable() { bool mustFlip; bool isPlayable = playerTrain.IsPlayable(hand, d12, out mustFlip); Assert.AreEqual(true, isPlayable); Assert.AreEqual(false, mustFlip); }
public void IsPlayable1() { // Tests the boolean IsPlayable method, it should pass // even though p12 isn't open because it is our hand bool mustFlip = false; Assert.True(p12.IsPlayable(h, d12_4, out mustFlip)); }
public void TestIsPlayable() { bool mustFlip; Domino d67 = new Domino(6, 7); Domino d76 = new Domino(7, 6); Assert.False(p2Train.IsPlayable(h1, d67, out mustFlip)); Assert.True(p1Train.IsPlayable(h1, d67, out mustFlip)); Assert.False(p1Train.IsPlayable(h2, d76, out mustFlip)); Assert.True(p1Train.IsPlayable(h1, d76, out mustFlip)); }
private void pictureBox2_DragEnter(object sender, DragEventArgs e) { PictureBox trainPB = (PictureBox)sender; Domino d = (Domino)e.Data.GetData("MTDClasses.Domino"); bool mustFlip = false; if (userTrain.IsPlayable(d, out mustFlip)) { e.Effect = DragDropEffects.Move; } else { e.Effect = DragDropEffects.None; } }
private void trainPB_DragEnter(object sender, DragEventArgs e) { PictureBox trainPB = (PictureBox)sender; string whichTrain = trainPB.Name.Substring(0, 3); Domino d = (Domino)e.Data.GetData("MTDClasses.Domino"); bool mustFlip = false; switch (whichTrain) { case "use": if (userTrain.IsPlayable(d, out mustFlip)) { e.Effect = DragDropEffects.Move; } else { e.Effect = DragDropEffects.None; } break; case "mex": if (mexicanTrain.IsPlayable(d, out mustFlip)) { e.Effect = DragDropEffects.Move; } else { e.Effect = DragDropEffects.None; } break; case "com": if (computerTrain.IsPlayable(d, out mustFlip)) { e.Effect = DragDropEffects.Move; } else { e.Effect = DragDropEffects.None; } break; } }
private static void TestPTIsPlayable() { Console.WriteLine("Test PlayerTrain IsPlayable"); Console.WriteLine(); const int MAXDOTS = 6; BoneYard b = new BoneYard(MAXDOTS); b.Shuffle(); Random rndGen = new Random(); int engVal = rndGen.Next(1, 7); PlayerTrain test = new PlayerTrain(new Hand(), engVal); const int LOOPS = 10; Console.WriteLine("Engine value = " + engVal); Console.WriteLine("Playable value = " + test.PlayableValue); Console.WriteLine(); Domino d; for (int i = 0; i < LOOPS; i++) { d = b.Draw(); Console.WriteLine(d.ToString()); if (rndGen.Next(1, 3) % 2 == 0) { test.Open(); Console.WriteLine("The player's hand is open"); } else { test.Close(); Console.WriteLine("The player's hand is closed"); } Console.WriteLine(); bool checkPlay = test.IsOpen && (d.Side1 == test.PlayableValue || d.Side2 == test.PlayableValue); bool checkFlip = checkPlay ? d.Side1 != test.PlayableValue : false; // Good form? Console.WriteLine("Test IsPlayable"); Console.WriteLine("Expect: " + checkPlay.ToString()); Console.WriteLine("Result: " + test.IsPlayable(new Hand(), d, out bool mustFlip).ToString()); Console.WriteLine("Test mustFlip"); Console.WriteLine("Expect: " + checkFlip.ToString()); Console.WriteLine("Result: " + mustFlip.ToString()); Console.WriteLine(); } }
public void TestIsPlayable() { bool flip; MexicanTrain a = new MexicanTrain(4); PlayerTrain b = new PlayerTrain(hand1, 5); PlayerTrain c = new PlayerTrain(hand2, 6); hand1.Add(new Domino(4, 5)); hand1.Add(new Domino(5, 6)); hand1.Add(new Domino(6, 4)); hand2.Add(new Domino(4, 5)); hand2.Add(new Domino(5, 6)); hand2.Add(new Domino(6, 4)); Assert.True(a.IsPlayable(hand1, hand1[0], out flip)); Assert.True(!flip); Assert.True(a.IsPlayable(hand1, hand1[2], out flip)); Assert.True(flip); Assert.True(b.IsPlayable(hand1, hand1[0], out flip)); Assert.True(flip); Assert.True(b.IsPlayable(hand1, hand1[1], out flip)); Assert.True(!flip); Assert.True(c.IsPlayable(hand2, hand2[1], out flip)); Assert.True(flip); Assert.True(c.IsPlayable(hand2, hand2[2], out flip)); Assert.True(!flip); Assert.True(!b.IsPlayable(hand2, hand1[0], out flip)); Assert.True(!b.IsPlayable(hand2, hand1[1], out flip)); Assert.True(!b.IsOpen); b.Open(); Assert.True(b.IsOpen); Assert.True(b.IsPlayable(hand2, hand1[0], out flip)); Assert.True(b.IsPlayable(hand2, hand1[1], out flip)); b.Close(); Assert.True(!b.IsOpen); Assert.True(!b.IsPlayable(hand2, hand1[0], out flip)); Assert.True(!b.IsPlayable(hand2, hand1[1], out flip)); }
// when the user right clicks on a domino, a context sensitive menu appears that // let's the user know which train is playable. Green means playable. Red means not playable. // the event handler for the menu item is enabled and disabled appropriately. private void whichTrainMenu_Opening(object sender, CancelEventArgs e) { bool mustFlip = false; if (userDominoInPlay != null) { mexicanTrainItem.Click -= new System.EventHandler(this.mexicanTrainItem_Click); computerTrainItem.Click -= new System.EventHandler(this.computerTrainItem_Click); myTrainItem.Click -= new System.EventHandler(this.myTrainItem_Click); if (mexicanTrain.IsPlayable(userHand, userDominoInPlay, out mustFlip)) { mexicanTrainItem.ForeColor = Color.Green; mexicanTrainItem.Click += new System.EventHandler(this.mexicanTrainItem_Click); } else { mexicanTrainItem.ForeColor = Color.Red; } if (computerTrain.IsPlayable(userHand, userDominoInPlay, out mustFlip)) { computerTrainItem.ForeColor = Color.Green; computerTrainItem.Click += new System.EventHandler(this.computerTrainItem_Click); } else { computerTrainItem.ForeColor = Color.Red; } if (userTrain.IsPlayable(userHand, userDominoInPlay, out mustFlip)) { myTrainItem.ForeColor = Color.Green; myTrainItem.Click += new System.EventHandler(this.myTrainItem_Click); } else { myTrainItem.ForeColor = Color.Red; } } }
public void TestIsPlayableNoFlipYesPlay() { Domino playableNoFlip = new Domino(12, 11); Assert.True(playerOneTrain.IsPlayable(playerOne, playableNoFlip, out mustFlip)); }
public void TestIsPlayable() { Assert.IsTrue(pT.IsPlayable(h, d3, out bool mustFlip)); }
public void TestIsPlayable() { pt.Open(); Assert.True(pt.IsPlayable(h, d11, out bool?mustFlip)); }