Example #1
0
        private bool isValidCapture(Board i_GameBoard, string io_PositionFrom, string io_PositionTo,
                                    ref CheckersPiece io_CurrentChecker, List <CheckersPiece> i_RivalPieces, ref CheckersPiece io_RivalChecker)
        {
            bool   isValid = false;
            ushort rowIndex, colIndex;

            foreach (string positionFrom in Moves.Keys)
            {
                if (io_PositionFrom == positionFrom)
                {
                    if (isPositionInList(io_PositionTo, Moves[positionFrom]))
                    {
                        rowIndex          = i_GameBoard.GetIndexInBoard(ref io_PositionFrom, out colIndex);
                        io_CurrentChecker = CaptureUtils.FindCheckerPiece(rowIndex, colIndex, Pieces);

                        colIndex += (ushort)(io_PositionTo[k_ColIndex] - io_PositionFrom[k_ColIndex]);
                        rowIndex += (ushort)(io_PositionTo[k_RowIndex] - io_PositionFrom[k_RowIndex]);
                        getRivalPosition(ref rowIndex, ref colIndex, io_PositionTo[k_RowIndex] < io_PositionFrom[k_RowIndex],
                                         io_PositionTo[k_ColIndex] < io_PositionFrom[k_ColIndex]);
                        io_RivalChecker = CaptureUtils.FindCheckerPiece((ushort)rowIndex, (ushort)colIndex, i_RivalPieces);

                        isValid = true;
                        break;
                    }
                }
            }

            return(isValid);
        }
Example #2
0
        private bool isValidMove(Board i_GameBoard, string i_PositionFrom, string i_PositionTo, ref CheckersPiece io_CurrentChecker)
        {
            bool   isValid = false;
            ushort rowIndex, colIndex;

            foreach (string positionFrom in Moves.Keys)
            {
                if (i_PositionFrom == positionFrom)
                {
                    if (isPositionInList(i_PositionTo, Moves[positionFrom]))
                    {
                        rowIndex          = i_GameBoard.GetIndexInBoard(ref i_PositionFrom, out colIndex);
                        io_CurrentChecker = CaptureUtils.FindCheckerPiece(rowIndex, colIndex, Pieces);

                        isValid = true;
                        break;
                    }
                }
            }

            return(isValid);
        }