예제 #1
0
파일: Board.cs 프로젝트: Boaholic/Sorry
        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;
        }
예제 #2
0
 public SquareButton(Square pS)
     : base()
 {
     Visible = true;
     parentSquare = pS;
     //BackColor = Color.Transparent;
 }
예제 #3
0
 public void SquareTest()
 {
     Square testSquare = new Square();
     testSquare.IsOccupied();
     testSquare.occupied();
     testSquare.occupiedBy();
     testSquare.ownerPlayer();
     testSquare.highlighted();
     testSquare.SetOccupied();
 }
예제 #4
0
파일: Game.cs 프로젝트: Boaholic/Sorry
        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();
        }
예제 #5
0
파일: SquareTest.cs 프로젝트: BryantN/Sorry
 public void SquareTest()
 {
     Square testSquare = new Square();
     testSquare.IsOccupied();
     //testSquare.SetOccupied();
 }