Exemple #1
0
        // Violating SRP by Checking for game over and setting up winner in the same method
        // but it makes sense to keep them together
        public bool IsGameOver()
        {
            bool hasAPlayerWon;
            var result = _gameBoard.IsGameOver(out hasAPlayerWon);

            if (hasAPlayerWon)
                Winner = CurrentPlayer;

            return result;
        }
Exemple #2
0
        public TicTacToeGame(IGameBoard gameBoard, IDisplayHelper displayHelper, IRandomNumberGenerator randomNumberGenerator)
        {
            _gameBoard = gameBoard;
            _displayHelper = displayHelper;
            _randomNumberGenerator = randomNumberGenerator;

            // Started with player factory but I think it was over engineered so replaced it with direct player creations
            PlayerO = new Player('O');
            PlayerX = new Player('X');
        }
Exemple #3
0
 public void Reset()
 {
     _gameBoard.Reset();
     Winner = null;
 }