コード例 #1
0
        private void moveChecker(GameBoard i_Board, Point i_Start, Point i_End)
        {
            bool isKing = i_Board.GetChecker(i_Start.GetX(), i_Start.GetY()).IsKing;
            char color  = i_Board.GetChecker(i_Start.GetX(), i_Start.GetY()).Color;

            i_Board.GetSquare(i_End.GetX(), i_End.GetY()).SetChecker(color, isKing);
            i_Board.GetSquare(i_Start.GetX(), i_Start.GetY()).ClearSquare();
        }
コード例 #2
0
        private bool ifLegalMoveManThenMove(GameBoard i_Board, Point i_Start, Point i_End, char i_PlayerColor, int addX, int addY)
        {
            int  startX = i_Start.GetX();
            int  startY = i_Start.GetY();
            int  endX   = i_End.GetX();
            int  endY   = i_End.GetY();
            bool res    = true;

            if (((startX + addX == endX) && (startY - addY == endY)) || ((startX + addX == endX) && (startY + addY == endY)))
            {
                moveChecker(i_Board, i_Start, i_End);
                m_DidCapture = false;
            }
            else if ((startX + (addX * 2) == endX) && (startY + (addY * 2) == endY))
            {
                if (i_Board.GetChecker(startX + addX, startY + addY) != null && (i_Board.GetChecker(startX + addX, startY + addY).Color != i_PlayerColor))
                {
                    moveChecker(i_Board, i_Start, i_End);
                    m_DidCapture = true;
                    i_Board.GetSquare(startX + addX, startY + addY).ClearSquare(); // remove the eaten one
                }
                else
                {
                    res = false;
                }
            }
            else if ((startX + (addX * 2) == endX) && (startY - (addY * 2) == endY))
            {
                if (i_Board.GetChecker(startX + addX, startY - addY) != null && (i_Board.GetChecker(startX + addX, startY - addY).Color != i_PlayerColor))
                {
                    moveChecker(i_Board, i_Start, i_End);
                    m_DidCapture = true;
                    i_Board.GetSquare(startX + addX, startY - addY).ClearSquare(); // remove the eaten one
                }
                else
                {
                    res = false;
                }
            }
            else
            {
                res = false;
            }

            return(res);
        }