Exemple #1
0
 public void SetUp()
 {
     MexT  = new MainTrain(12);
     d1212 = new Domino(12, 12);
     d512  = new Domino(5, 12);
     d125  = new Domino(12, 5);
     d55   = new Domino(5, 5);
 }
Exemple #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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
 // adds a domino picture to a train
 public void ComputerPlayOnTrain(Domino d, MainTrain train, List <PictureBox> trainPBs, int pbIndex)
 {
 }