/// <summary> /// Get a move /// </summary> /// <returns>The move</returns> public IMove GetMove() { var currentMove = mp.GetMove(); return(currentMove); // get the move from the move provider // set the move owner to the current player (using "this") since this is used during validation }
/// <summary> /// Helper function to perform a single turn /// Very useful for unit testing /// </summary> public void PerformSingleTurn(IPlayer player) { // validate the arguments // if player is null, throw an ArgumentNullException if (player == null) { throw new ArgumentNullException(); } // tell the player it's their turn using their name, and ask them for their move // using the output provider to print // TODO: CHANGE WHEN UI IS IMPLEMENTED Console.WriteLine($"{player.Name}, it's your turn. Where would you like to move?"); // set game state to WaitingForUserInput GameState = GameState.WaitingForUserInput; // get the move from the player var column = Convert.ToInt32(Console.ReadLine()); var move = moveProvider.GetMove(column); // set game state to PerformingMove GameState = GameState.PerformingMove; // create a piece with the player as the owner // TO DO BY VILDE // make a move using the board, passing in that piece board.AddPiece(piece, move); // set game state to CheckingForGameOver GameState = GameState.CheckingForGameOver; // Did the current player win? (ask the win checker) // If yes, change the game state to GameState.Winner and return if (winChecker.IsWin(board, move)) { GameState = GameState.Winner; } // Is the board full? (ask the board) // If yes, change the game state to GameState.Draw if (board.IsFull()) { GameState = GameState.Draw; } }