Ejemplo n.º 1
0
        public void PlayerForfit(Player i_PlayerForfit, out eMoveStatus i_CurrentMoveStatus)
        {
            int forfitPlayerPoints = i_PlayerForfit.PlayerPosition == ePlayerPosition.BottomPlayer
                                         ? m_BottomPlayerPoints
                                         : m_TopPlayerPoints;
            int otherPlayerPoints = i_PlayerForfit.PlayerPosition == ePlayerPosition.BottomPlayer
                                        ? m_TopPlayerPoints
                                        : m_BottomPlayerPoints;

            if (forfitPlayerPoints <= otherPlayerPoints)
            {
                i_CurrentMoveStatus = eMoveStatus.Legal;
                m_PlayerHasForfit   = true;
                m_PlayerForfit      = i_PlayerForfit.PlayerPosition;
            }
            else
            {
                i_CurrentMoveStatus = eMoveStatus.Illegal;
            }
        }
Ejemplo n.º 2
0
 public void MovePiece(ref Move io_Move, Move i_PreviousMove, out eMoveStatus o_MoveStatus)
 {
     o_MoveStatus = eMoveStatus.Illegal;
     if (checkMoveLegality(ref io_Move, i_PreviousMove))
     {
         o_MoveStatus = eMoveStatus.Legal;
         changePiecePosition(io_Move);
         checkKing(io_Move.End);
         if (io_Move.Type == eMoveType.Jump)
         {
             removedJumpedOverPiece(io_Move);
             if (isJumpPossible(possibleMovesForPiece(io_Move.End), out List <Move> jumpsList))
             {
                 o_MoveStatus = eMoveStatus.AnotherJumpPossible;
             }
         }
     }
     else
     {
         o_MoveStatus = eMoveStatus.Illegal;
     }
 }
Ejemplo n.º 3
0
        private Move getMove(Move i_PreviousMove, out eMoveStatus o_MoveStatus)
        {
            Move        currentMove       = null;
            eMoveStatus currentMoveStatus = eMoveStatus.Illegal;

            if (m_CurrentPlayer.PlayerType == ePlayerType.Human)
            {
                while (currentMoveStatus == eMoveStatus.Illegal)
                {
                    currentMove = r_UI.GetUserMoveInput(m_CurrentPlayer, out bool forfitFlag);
                    if (forfitFlag)
                    {
                        m_Board.PlayerForfit(m_CurrentPlayer, out currentMoveStatus);
                        if (currentMoveStatus == eMoveStatus.Illegal)
                        {
                            r_UI.NotAllowedForfit();
                        }
                    }
                    else
                    {
                        m_Board.MovePiece(ref currentMove, i_PreviousMove, out currentMoveStatus);
                        if (currentMoveStatus == eMoveStatus.Illegal)
                        {
                            r_UI.InValidMove();
                        }
                    }
                }
            }
            else
            {
                currentMove = m_Board.GetRandomMove(m_CurrentPlayer.PlayerPosition, i_PreviousMove);
                m_Board.MovePiece(ref currentMove, i_PreviousMove, out currentMoveStatus);
            }

            o_MoveStatus = currentMoveStatus;

            return(currentMove);
        }