Example #1
0
        public void TestIsPlayable()
        {
            bool         flip    = false;
            PrivateTrain myTrain = new PrivateTrain(myHand, 3);

            Assert.True(myTrain.IsPlayable(d31, out flip, myHand));
            Assert.False(myTrain.IsPlayable(d55, out flip, myHand));
            Assert.False(myTrain.IsPlayable(d31, out flip, yourHand));
            myTrain.Open();
            Assert.True(myTrain.IsPlayable(d31, out flip, yourHand));
        }
Example #2
0
 public void SetUp()
 {
     by    = new BoneYard(12);
     pHand = new Hand(by);
     cHand = new Hand(by);
     d1212 = new Domino(12, 12);
     d125  = new Domino(12, 5);
     d512  = new Domino(5, 12);
     d55   = new Domino(5, 5);
     ppT   = new PrivateTrain(pHand, 12);
     cpT   = new PrivateTrain(cHand, 12);
 }
Example #3
0
 public void SetUpAllTests()
 {
     h1       = new Hand();
     pt1      = new PrivateTrain(h1);
     pt2      = new PrivateTrain(h1, 7);
     myHand   = new Hand();
     yourHand = new Hand();
     d11      = new Domino(1, 1);
     d13      = new Domino(1, 3);
     d14      = new Domino(1, 4);
     d31      = new Domino(3, 1);
     d34      = new Domino(3, 4);
     d55      = new Domino(5, 5);
 }
Example #4
0
        internal CustomBasicList <SKRect> GetClickableRectangle(PrivateTrain thisPrivate)
        {
            // will return 2 rectangles.
            var    firstRect  = thisPrivate.DominoArea;
            var    secondRect = thisPrivate.TrainArea;
            SKSize thisSize;

            thisSize = GetActualSize(firstRect.Width, firstRect.Height);
            var ThisPoint = GetActualPoint(firstRect.Location);
            CustomBasicList <SKRect> tempList = new CustomBasicList <SKRect>
            {
                SKRect.Create(ThisPoint, thisSize)
            };

            thisSize  = GetActualSize(secondRect.Width, secondRect.Height);
            ThisPoint = GetActualPoint(secondRect.Location);
            tempList.Add(SKRect.Create(ThisPoint, thisSize));
            return(tempList);
        }
Example #5
0
        private SKPoint DominoLocationNeeded(PrivateTrain thisPrivate, int whichOne, bool doubles)
        {
            var    widths = GetWidths();
            SKRect thisArea;
            var    thisSize  = GetActualSize(thisPrivate.DominoArea.Size.Width, thisPrivate.DominoArea.Size.Height);
            var    thisPoint = GetActualPoint(thisPrivate.DominoArea.Location);

            thisArea = SKRect.Create(thisPoint, thisSize);
            if (thisPrivate.IsRotated == true)
            {
                if (whichOne == 1)
                {
                    if (thisPrivate.IsOpposite == true)
                    {
                        return(new SKPoint(FindCenter(thisArea.Location.X, doubles), thisArea.Bottom - widths));
                    }
                    return(new SKPoint(FindCenter(thisArea.Location.X, doubles), FindTopLeft(thisArea.Top, doubles)));
                }
                if (thisPrivate.IsOpposite == true)
                {
                    return(new SKPoint(FindCenter(thisArea.Location.X, doubles), thisArea.Location.Y));
                }
                return(new SKPoint(FindCenter(thisArea.Location.X, doubles), FindTopLeft(thisArea.Bottom - widths, doubles)));
            }
            if (whichOne == 1)
            {
                if (thisPrivate.IsOpposite == true)
                {
                    return(new SKPoint(thisArea.Right - widths, FindCenter(thisArea.Location.Y, doubles)));
                }
                return(new SKPoint(FindTopLeft(thisArea.Location.X, doubles), FindCenter(thisArea.Location.Y, doubles)));
            }
            if (thisPrivate.IsOpposite == true)
            {
                return(new SKPoint(thisArea.Location.X, FindCenter(thisArea.Location.Y, doubles)));
            }
            return(new SKPoint(FindTopLeft(thisArea.Right - widths, doubles), FindCenter(thisArea.Location.Y, doubles)));
        }
Example #6
0
        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;
        }
Example #7
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);
        }
Example #8
0
 public void SetUpAllTests()
 {
     dummyDomino         = new Domino(12, 12);
     defaultHand         = new Hand();
     defaultPrivateTrain = new PrivateTrain();
 }
Example #9
0
        public void FirstLoad()
        {
            if (PrivateList.Count > 0)
            {
                throw new Exception("Cannot load the private list again because there are already items on the list");
            }
            PrivateTrain thisPrivate;
            int          x;

            for (x = 1; x <= 8; x++)
            {
                thisPrivate = new PrivateTrain();
                if (x == 1)
                {
                    thisPrivate.DominoArea = SKRect.Create(150, 12, 95, 143);
                    thisPrivate.TrainArea  = SKRect.Create(175, 155, 70, 28);
                    thisPrivate.IsRotated  = true; // domino
                    thisPrivate.IsOpposite = true;
                }
                else if (x == 2)
                {
                    thisPrivate.DominoArea = SKRect.Create(255, 12, 95, 143);
                    thisPrivate.TrainArea  = SKRect.Create(280, 155, 70, 28);
                    thisPrivate.IsRotated  = true; // domino
                    thisPrivate.IsOpposite = true;
                }
                else if (x == 3)
                {
                    thisPrivate.DominoArea = SKRect.Create(350, 155, 143, 95);
                    // this piece will need to be rotated for the train piece (well see)
                    thisPrivate.TrainArea  = SKRect.Create(305, 184, 45, 50);
                    thisPrivate.IsRotated  = false;
                    thisPrivate.IsOpposite = false;
                }
                else if (x == 4)
                {
                    thisPrivate.DominoArea = SKRect.Create(350, 260, 143, 95);
                    thisPrivate.TrainArea  = SKRect.Create(305, 276, 45, 50);
                    thisPrivate.IsBottom   = true;
                    thisPrivate.IsRotated  = false;
                    thisPrivate.IsOpposite = false;
                }
                else if (x == 5)
                {
                    thisPrivate.DominoArea = SKRect.Create(255, 355, 95, 143);
                    thisPrivate.TrainArea  = SKRect.Create(280, 327, 70, 28);
                    thisPrivate.IsRotated  = true;
                    thisPrivate.IsOpposite = false;
                }
                else if (x == 6)
                {
                    thisPrivate.DominoArea = SKRect.Create(150, 355, 95, 143);
                    thisPrivate.TrainArea  = SKRect.Create(175, 327, 70, 28);
                    thisPrivate.IsRotated  = true;
                    thisPrivate.IsOpposite = false;
                }
                else if (x == 7)
                {
                    thisPrivate.DominoArea = SKRect.Create(7, 260, 143, 95);
                    thisPrivate.TrainArea  = SKRect.Create(150, 276, 45, 50);
                    thisPrivate.IsBottom   = true;
                    thisPrivate.IsRotated  = false;
                    thisPrivate.IsOpposite = true;
                }
                else if (x == 8)
                {
                    thisPrivate.DominoArea = SKRect.Create(7, 155, 143, 95);
                    thisPrivate.TrainArea  = SKRect.Create(150, 184, 45, 50);
                    thisPrivate.IsRotated  = false;
                    thisPrivate.IsOpposite = true;
                }
                PrivateList.Add(x, thisPrivate);
            }
        }