/// <summary> /// Attempt to get a valid player move. /// If the player chooses a location that is taken, the CurrentRoundState remains unchanged, /// the player is given a message indicating so, and the game loop is cycled to allow the player /// to make a new choice. /// </summary> /// <param name="currentPlayerPiece">identify as either the X or O player</param> private void ManagePlayerTurn(Gameboard.PlayerPiece currentPlayerPiece) { GameboardPosition gameboardPosition = _gameView.GetPlayerPositionChoice(); if (_gameView.CurrentViewState != ConsoleView.ViewState.PlayerUsedMaxAttempts) { try { // // player chose an open position on the game board, add it to the game board // if (_gameboard.GameboardPositionAvailable(gameboardPosition)) { _gameboard.SetPlayerPiece(gameboardPosition, currentPlayerPiece); } // // player chose a taken position on the game board // else { _gameView.DisplayGamePositionChoiceNotAvailableScreen(); } } catch (Gameboard.GamePositionException pe) { _gameView.DisplayGamePositionChoiceNotAvailableScreen(); Console.WriteLine(pe.Message); } } }
/// <summary> /// Attempt to get a valid player move. /// If the player chooses a location that is taken, the CurrentRoundState remains unchanged, /// the player is given a message indicating so, and the game loop is cycled to allow the player /// to make a new choice. /// </summary> /// <param name="currentPlayerPiece">identify as either the X or O player</param> private void ManagePlayerTurn(Gameboard.PlayerPiece currentPlayerPiece) { int column = _gameView.PlayerCoordinateChoice(); while (column == _gameboard.HELP_CODE) { _gameView.DisplayGameRules(); _gameView.DisplayGameArea(); column = _gameView.PlayerCoordinateChoice(); } if (column == _gameboard.EXIT_ROUND_CODE) { _numberOfCatsGames++; _playingRound = false; _gameView.DisplayCurrentGameStatus(_roundNumber, _playerXNumberOfWins, _playerONumberOfWins, _numberOfCatsGames); return; } // // player chose an open position on the game board, add it to the game board // if (_gameboard.GameboardColumnAvailable(column - 1)) { _gameboard.SetPlayerPiece(column, currentPlayerPiece); // // Evaluate and update the current game board state // _gameboard.UpdateGameboardState(column - 1, applause); } }
/// <summary> /// Attempt to get a valid player move. /// If the player chooses a location that is taken, the CurrentRoundState remains unchanged, /// the player is given a message indicating so, and the game loop is cycled to allow the player /// to make a new choice. /// </summary> /// <param name="currentPlayerPiece">identify as either the X or O player</param> private void ManagePlayerTurn(Gameboard.PlayerPiece currentPlayerPiece) { GameboardPosition gameboardPosition = _gameView.GetPlayerPositionChoice(); if (_gameView.CurrentViewState == ConsoleView.ViewState.ViewCurrentStats) { _gameView.DisplayCurrentGameStatus(_roundNumber, _playerXNumberOfWins, _playerONumberOfWins, _numberOfCatsGames); _gameView.CurrentViewState = ConsoleView.ViewState.Active; _gameView.DisplayGameArea(); gameboardPosition = _gameView.GetPlayerPositionChoice(); } if (_gameView.CurrentViewState != ConsoleView.ViewState.ResetCurrentRound) { // //Proceed with turn as normal. // if (_gameView.CurrentViewState != ConsoleView.ViewState.PlayerUsedMaxAttempts) { // // player chose an open position on the game board, add it to the game board // if (_gameboard.GameboardPositionAvailable(gameboardPosition)) { _gameboard.SetPlayerPiece(gameboardPosition, currentPlayerPiece); } // // player chose a taken position on the game board // else { _gameView.DisplayGamePositionChoiceNotAvailableScreen(); } } } }