Esempio n. 1
0
        public void Isplayable()
        {
            bool mustFlip;

            Assert.IsTrue(MexT.IsPlayable(d512, out mustFlip));
            Assert.IsTrue(mustFlip);
            Assert.IsFalse(MexT.IsPlayable(d55, out mustFlip));
        }
Esempio n. 2
0
        // plays a domino on a train.  Loads the appropriate train pb,
        // removes the domino pb from the hand, updates the train status label ,
        // disables the hand pbs and disables appropriate buttons
        public void UserPlayOnTrain(Domino d, MainTrain train, List <PictureBox> trainPBs)
        {
            bool pbfilled = false;
            bool mustFlip;

            train.IsPlayable(d, out mustFlip);
            train.Play(d);
            player.listOfDominos.Remove(d);

            foreach (PictureBox pb in trainPBs)
            {
                if (pb.Image == null)
                {
                    LoadDomino(pb, d);
                    if (mustFlip == true)
                    {
                        PictureBox temp = new PictureBox();
                        temp.Image = pb.Image;
                        temp.Image.RotateFlip(RotateFlipType.RotateNoneFlipY);
                        pb.Image = temp.Image;
                        mustFlip = false;
                    }
                    break;
                }
                if (trainPBs.IndexOf(pb) == 4)
                {
                    pbfilled = true;
                }
            }
            foreach (PictureBox pb in trainPBs)
            {
                if (pbfilled == true)
                {
                    int index = trainPBs.IndexOf(pb);
                    if (index == 4)
                    {
                        LoadDomino(pb, d);
                        if (mustFlip == true)
                        {
                            PictureBox temp = new PictureBox();
                            temp.Image = pb.Image;
                            temp.Image.RotateFlip(RotateFlipType.RotateNoneFlipY);
                            pb.Image = temp.Image;
                            mustFlip = false;
                        }
                        break;
                    }
                    else
                    {
                        pb.Image = trainPBs[index + 1].Image;
                    }
                }
            }

            ReloadPBS();
            EnableUserHandPBs(pictureBoxes);
        }
Esempio n. 3
0
        // 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);
                Hand userHand = player;

                if (maintrain.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 (playerTrain.IsPlayable(userHand, userDominoInPlay, out mustFlip))
                {
                    myTrainItem.ForeColor = Color.Green;
                    myTrainItem.Click    += new System.EventHandler(this.myTrainItem_Click);
                }
                else
                {
                    myTrainItem.ForeColor = Color.Red;
                }
            }
        }