Beispiel #1
0
        private void currPlayerTurn(ePlayerStatus i_CurrPlayerStatus, int i_CurrRow, int i_CurrCol, int i_NextRow, int i_NextCol)
        {
            bool isContinuousJump = false;

            eMoveList moveType;
            int       currRow = i_CurrRow, currCol = i_CurrCol, nextRow = i_NextRow, nextCol = i_NextCol;

            moveType = returnValidMove(ref currRow, ref currCol, ref nextRow, ref nextCol); // get the user's move type (jump, move) if the input is invalid then returnValidMove loops until valid input is recieved

            //// must jump (also check continuous jump)
            if (i_CurrPlayerStatus == ePlayerStatus.MustJump || isContinuousJump == true)
            {
                if (moveType.ToString().Contains("Jump"))
                {
                    m_CurrentPlayer.checkersPieceMovement(m_CheckersBoard.CheckerBoard, currRow, currCol, nextRow, nextCol, m_CheckersBoard.CheckerBoard[currRow, currCol], moveType);
                    i_CurrPlayerStatus = checkAvailableMoves(); // check if continuous jumps are available
                    m_ChessPieceMoved.Invoke();

                    if (i_CurrPlayerStatus != ePlayerStatus.MustJump)
                    {
                        turnEnd();
                        isContinuousJump = false;
                    }
                    else
                    {
                        isContinuousJump = true;
                        m_CurrJumpRow    = nextRow;
                        m_CurrJumpCol    = nextCol;
                    }
                }
                else if (isContinuousJump == false)
                {
                    if (moveType.ToString().Contains("Jump"))
                    {
                        m_CurrentPlayer.checkersPieceMovement(m_CheckersBoard.CheckerBoard, currRow, currCol, nextRow, nextCol, m_CheckersBoard.CheckerBoard[currRow, currCol], moveType); // updates matrix and notifies form's matrix update

                        m_ChessPieceMoved.Invoke();

                        i_CurrPlayerStatus = checkAvailableMoves(); // check if continuous jumps are available

                        if (i_CurrPlayerStatus != ePlayerStatus.MustJump)
                        {
                            turnEnd();
                        }
                    }
                    else
                    {
                        MessageBox.Show("You must jump", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                //// regular move, already received valid move
                if (moveType != eMoveList.Quit && moveType != eMoveList.InvalidMove)
                {
                    //// move/erase the checkers piece(s) after valid play
                    m_CurrentPlayer.checkersPieceMovement(m_CheckersBoard.CheckerBoard, currRow, currCol, nextRow, nextCol, m_CheckersBoard.CheckerBoard[currRow, currCol], moveType); // updates matrix and notifies form's matrix update
                    m_ChessPieceMoved.Invoke();
                    turnEnd();
                }
                else
                {
                    MessageBox.Show("Invalid Player Move", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            i_CurrPlayerStatus = checkAvailableMoves();

            if (i_CurrPlayerStatus == ePlayerStatus.UnableToMove)
            {
                PlayerLose();
            }
        }