/// <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> /// Display the game area and game board /// </summary> public void DisplayGameArea() { ConsoleUtil.HeaderText = "Current Game Board"; ConsoleUtil.DisplayReset(); int minDefaultCol = 0; while (!_gameboard.GameboardColumnAvailable(minDefaultCol)) { if (minDefaultCol < 6) { minDefaultCol++; } else { break; } } int defaultPos = (34 + (4 * minDefaultCol)); DisplayGameboard(defaultPos); DisplayGameStatus(); }