Exemple #1
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);
        }
Exemple #2
0
 public void Play()
 {
     MexT.Play(d125);
     Assert.AreEqual(1, MexT.Count);
     Assert.AreEqual(5, MexT.PlayableValue);
 }