Example #1
0
        public bool GetMovesAndUpdate(Board i_GameBoard, User i_RivalPlayer)
        {
            bool canCapture = true;
            Dictionary <string, List <string> > moves = new Dictionary <string, List <string> >();

            // If the current checker didn't make a move the turn before.
            if (m_CurrentCheckerPiece == null)
            {
                // If the user can eat, he must! the list will return as ref value. If not, the list will return the regular moves list.
                if (!CaptureUtils.CanUserCapture(i_GameBoard, this, i_RivalPlayer, ref moves))
                {
                    m_Moves    = MoveUtils.CreateRegularMoves(this, i_GameBoard);
                    canCapture = false;
                }
                else
                {
                    m_Moves = moves;
                }
            }
            // If there's a "soldier" that can capture again.
            else
            {
                // If there's capture in a row.
                m_Moves = createCaptureMoveList(i_GameBoard, i_RivalPlayer);
            }

            return(canCapture);
        }
Example #2
0
 public void MakeUserMove(ref Board io_GameBoard, ref CheckersPiece io_CurrentChecker, string i_PositionFrom, string i_PositionTo)
 {
     if (!io_CurrentChecker.IsKing)
     {
         MoveUtils.MoveTool(ref io_GameBoard, ref io_CurrentChecker, i_PositionTo);
         MakeToolAKing(io_GameBoard, ref io_CurrentChecker);
     }
     else
     {
         MoveUtils.MoveTool(ref io_GameBoard, ref io_CurrentChecker, i_PositionTo);
     }
 }
Example #3
0
        // Computer Player Methods:
        public void MakeComputerMove(ref Board io_GameBoard, ref CheckersPiece io_CurrentChecker)
        {
            string[] positions = getRandomMove(io_GameBoard, ref io_CurrentChecker);

            if (!io_CurrentChecker.IsKing)
            {
                MoveUtils.MoveTool(ref io_GameBoard, ref io_CurrentChecker, positions[1]);
                MakeToolAKing(io_GameBoard, ref io_CurrentChecker);
            }
            else
            {
                MoveUtils.MoveTool(ref io_GameBoard, ref io_CurrentChecker, positions[1]);
            }
        }
Example #4
0
        private static bool tryInsertCapturePosition(
            Board i_GameBoard, CheckersPiece i_CurrentChecker,
            ushort i_RowIndex, ushort i_ColIndex,
            CheckersPiece i_RivalChecker, ref Dictionary <string, List <string> > io_CapturePositions)
        {
            bool canInsert = false;

            if (i_RivalChecker != null && isAvailableCaptureCell(i_GameBoard, i_RowIndex, i_ColIndex))
            {
                string captureIndex = MoveUtils.GetStringIndexes(i_RowIndex, i_ColIndex);
                MoveUtils.AddToDict(ref io_CapturePositions, i_CurrentChecker, captureIndex);
                canInsert = true;
            }

            return(canInsert);
        }