Exemplo n.º 1
0
        public eRoundOptions PlayObligatoryMove(Player i_CurrentPlayer, ref Move io_InputMove)
        {
            eRoundOptions obligitoryMoveRes = eRoundOptions.passRound;

            if (i_CurrentPlayer.IsMoveObligatory(io_InputMove))
            {   // Move was one of the obligatory options
                if (this.EliminateOpponent(io_InputMove, i_CurrentPlayer))
                {
                    i_CurrentPlayer.UpdateObligatoryMoves(this.m_Board);
                    if (i_CurrentPlayer.ObligatoryMovesCount > Move.k_ZeroObligatoryMoves)
                    {
                        obligitoryMoveRes = eRoundOptions.currentPlayerHasAnotherRound;
                    }
                }
                else
                {
                    obligitoryMoveRes = eRoundOptions.playerEnteredInvalidMove;
                }
            }
            else
            {
                obligitoryMoveRes = eRoundOptions.playerDidntEnterObligatoryMove;
            }

            return(obligitoryMoveRes);
        }
Exemplo n.º 2
0
        public eRoundOptions NewRound(string i_UserMove)
        {
            Player currentPlayer;
            Move   inputMove = Move.Parse(i_UserMove);

            Square.eSquareType weakPlayer;
            bool          moveWasSuccessful;
            eRoundOptions roundStatus = eRoundOptions.passRound;

            currentPlayer = this.GetCurrentPlayer();
            currentPlayer.UpdateObligatoryMoves(this.m_Board);
            currentPlayer.UpdateAvailableMovesIndicator(this.m_Board);
            weakPlayer = this.GetWeakPlayer();

            inputMove = Move.Parse(i_UserMove);

            if (i_UserMove.ToUpper() == k_QuitGameChar)
            {
                if (currentPlayer.PlayerType == weakPlayer)
                {
                    this.endRoundScoreUpdate(currentPlayer.PlayerType);
                    roundStatus = eRoundOptions.weakPlayerQuits;
                }
                else
                {
                    this.m_TurnCounter--;
                    roundStatus = eRoundOptions.strongPlayerWantsToQuit;
                }
            }
            else if (currentPlayer.ObligatoryMovesCount > Move.k_ZeroObligatoryMoves)
            {
                roundStatus = this.PlayObligatoryMove(currentPlayer, ref inputMove);
                if (roundStatus != eRoundOptions.passRound)
                {
                    this.m_TurnCounter--;
                }
            }
            else if (currentPlayer.HasAvailableMove)
            {
                bool needToEliminate = true;
                moveWasSuccessful = this.m_Board.UpdateBoardAfterMove(inputMove, currentPlayer, !needToEliminate);
                if (!moveWasSuccessful)
                {
                    roundStatus = eRoundOptions.playerEnteredInvalidMove;
                    this.m_TurnCounter--;
                }
            }
            else
            {
                roundStatus = eRoundOptions.passRound;
            }

            this.m_TurnCounter++;

            return(roundStatus);
        }
        public eRoundOptions NewRound(string i_UserMove)
        {
            Move inputMove = Move.Parse(i_UserMove);

            Square.eSquareType weakPlayer;
            bool          moveWasSuccessful;
            eRoundOptions roundStatus = eRoundOptions.passRound;

            this.m_CurrentPlayer = this.GetCurrentPlayer();
            this.m_CurrentPlayer.UpdateObligatoryMoves(this.m_Board, null);
            this.m_CurrentPlayer.UpdateAvailableMovesIndicator(this.m_Board);
            weakPlayer = this.GetWeakPlayer();
            inputMove  = Move.Parse(i_UserMove);

            if (this.m_CurrentPlayer.ObligatoryMovesCount > Move.k_ZeroObligatoryMoves)
            {
                roundStatus = this.PlayObligatoryMove(this.m_CurrentPlayer, ref inputMove);
                if (roundStatus != eRoundOptions.passRound)
                {
                    this.m_TurnCounter--;
                }
            }
            else if (this.m_CurrentPlayer.HasAvailableMove)
            {
                bool needToEliminate = true;
                moveWasSuccessful = this.m_Board.UpdateBoardAfterMove(inputMove, this.m_CurrentPlayer, !needToEliminate);
                if (!moveWasSuccessful)
                {
                    roundStatus = eRoundOptions.playerEnteredInvalidMove;
                    this.m_TurnCounter--;
                }
            }

            roundStatus = this.CheckGameStatus(roundStatus);

            if (roundStatus == eRoundOptions.playerTwoWon)
            {
                this.m_CurrentPlayer = this.m_PlayerTwo;
                this.endRoundScoreUpdate(Square.eSquareType.playerOne);
            }
            else if (roundStatus == eRoundOptions.playerOneWon)
            {
                this.m_CurrentPlayer = this.m_PlayerOne;
                this.endRoundScoreUpdate(Square.eSquareType.playerTwo);
            }
            else
            {
                this.m_TurnCounter++;
                this.m_CurrentPlayer = this.GetCurrentPlayer();
            }

            return(roundStatus);
        }
Exemplo n.º 4
0
        public eRoundOptions CheckGameStatus()
        {
            eRoundOptions gameStatus = eRoundOptions.passRound;

            if (!this.m_PlayerOne.HasAvailableMove && !this.m_PlayerTwo.HasAvailableMove)
            {
                gameStatus = eRoundOptions.gameIsATie;
            }

            if (this.m_PlayerOne.SquaresNum == 0 || !this.m_PlayerOne.HasAvailableMove)
            {
                gameStatus = eRoundOptions.playerTwoWon;
            }
            else if (this.m_PlayerTwo.SquaresNum == 0 || !this.m_PlayerTwo.HasAvailableMove)
            {
                gameStatus = eRoundOptions.playerOneWon;
            }

            return(gameStatus);
        }
        public eRoundOptions CheckGameStatus(eRoundOptions i_CurrentStatus)
        {
            eRoundOptions gameStatus = i_CurrentStatus;

            this.PlayerOne.UpdateAvailableMovesIndicator(this.m_Board);
            this.PlayerTwo.UpdateAvailableMovesIndicator(this.m_Board);

            if (!this.m_PlayerOne.HasAvailableMove && !this.m_PlayerTwo.HasAvailableMove)
            {
                gameStatus = eRoundOptions.gameIsATie;
            }

            if (this.m_PlayerOne.SquaresNum == 0 || !this.m_PlayerOne.HasAvailableMove)
            {
                gameStatus = eRoundOptions.playerTwoWon;
            }
            else if (this.m_PlayerTwo.SquaresNum == 0 || !this.m_PlayerTwo.HasAvailableMove)
            {
                gameStatus = eRoundOptions.playerOneWon;
            }

            return(gameStatus);
        }