Example #1
0
 private static void EngineSetUp(out Renderer renderer, out WinReferee winReferee, Symbol humanPlayer1Symbol, Symbol humanPlayer2Symbol, out HumanPlayer humanPlayerOne, out HumanPlayer humanPlayerTwo)
 {
     renderer       = new Renderer();
     winReferee     = new WinReferee();
     humanPlayerOne = new HumanPlayer(humanPlayer1Symbol, new InputChecker());
     humanPlayerTwo = new HumanPlayer(humanPlayer2Symbol, new InputChecker());
 }
Example #2
0
 private static bool CheckIfPlayerIsWinner(GameBoard board, Symbol symbol, WinReferee winReferee, out Symbol winner)
 {
     winner = winReferee.WinChecker(board, symbol);
     winReferee.AnnounceWinner(winner);
     if (winner != Symbol.Empty)
     {
         return(true);
     }
     if (BoardElementsNotEqualToEmptyThenBreak(board))
     {
         return(true);
     }
     return(false);
 }
Example #3
0
        private static Symbol PlayTicTacToe(GameBoard board, Symbol humanPlayer1Symbol, Renderer renderer,
                                            WinReferee winReferee,
                                            Symbol humanPlayer2Symbol, HumanPlayer humanPlayerOne, HumanPlayer humanPlayerTwo)
        {
            var winner = Symbol.Empty;

            while (AnyBoardElementsIsEqualToEmpty(board))
            {
                PlayerOneMove(board, renderer, humanPlayerOne);
                if (CheckIfPlayerIsWinner(board, humanPlayer1Symbol, winReferee, out winner))
                {
                    break;
                }
                PlayerTwoMove(board, renderer, humanPlayerTwo);
                if (CheckIfPlayerIsWinner(board, humanPlayer2Symbol, winReferee, out winner))
                {
                    break;
                }
            }
            return(winner);
        }