Exemplo n.º 1
0
        public bool validateDistance(Square start, Square end, int distance)
        {
            int x = 0, y = 0;
            int startx = 0, starty = 0;
            int endx = 0, endy = 0;
            foreach (var list in board)
            {
                foreach (var item in list)
                {
                    if (item == start)
                    {
                        startx = x;
                        starty = y;
                    }
                    if (item == end)
                    {
                        endx = x;
                        endy = y;
                    }
                    y++;
                }
                y = 0;
                x++;
            }

            //needs work, on the logic here
            if (endx - startx + endy - starty == distance)
            {
                return true;
            }
            return false;
        }
Exemplo n.º 2
0
 public SquareButton(Square pS)
     : base()
 {
     Visible = true;
     parentSquare = pS;
     //BackColor = Color.Transparent;
 }
Exemplo n.º 3
0
 public void SquareTest()
 {
     Square testSquare = new Square();
     testSquare.IsOccupied();
     testSquare.occupied();
     testSquare.occupiedBy();
     testSquare.ownerPlayer();
     testSquare.highlighted();
     testSquare.SetOccupied();
 }
Exemplo n.º 4
0
        public void SquareButtonPressed(object sender, EventArgs e)
        {
            var curSquareButton = (SquareButton)sender;
            var squarePressed = curSquareButton.parentSquare;
            if (prevCard == null)
                return;

            if (prevSquarePressed == null)
            {
                if (squarePressed.IsOccupied() != null && squarePressed.IsOccupied().ownerPlayer == currentPlayerTurn)
                {
                    prevSquarePressed = squarePressed;
                }

            }
            else
            {
                //logic comes in to play

                // we now need to validate the move
                switch (prevCard.cardVal)
                {
                    case Card.VALUE.One:
                        if (prevSquarePressed.type == SquareType.Start)
                        {
                            if (board.validateDistance(prevSquarePressed, squarePressed, 1)) {
                                squarePressed.SetOccupied(prevSquarePressed.IsOccupied());
                                prevSquarePressed.SetOccupied(null);
                            }
                        }
                        break;
                    case Card.VALUE.TWO:
                        break;
                    case Card.VALUE.THREE:
                        break;
                    case Card.VALUE.FOUR:
                        break;
                    case Card.VALUE.FIVE:
                        break;
                    case Card.VALUE.SEVEN:
                        break;
                    case Card.VALUE.EIGHT:
                        break;
                    case Card.VALUE.TEN:
                        break;
                    case Card.VALUE.ELEVEN:
                        break;
                    case Card.VALUE.TWELVE:
                        break;
                    case Card.VALUE.SORRY:
                        break;
                }
            }
            panel.Render();
        }
Exemplo n.º 5
0
 public void SquareTest()
 {
     Square testSquare = new Square();
     testSquare.IsOccupied();
     //testSquare.SetOccupied();
 }