Example #1
0
        public string PlayGame()
        {
            _userInterface.ClearPage();
            string message = $"WELCOME TO THE TENNIS GAME!\n{_playerA.Name} vs {_playerB.Name}: who is going to win this game?";

            _userInterface.ShowStrongMessage(message);
            string gameWinnerName = "";

            while (true)
            {
                PrintCurrentScore();

                _userInterface.ShowMessage("Press any key to play the point...");
                _userInterface.WaitUserAction();
                _userInterface.ClearPage();

                string pointWinnerPlayerName = _pointResultEngine.GetPointWinnerPlayerName(_playerA, _playerB);
                _userInterface.ShowMessage($"\n{pointWinnerPlayerName} won the point.");

                _gameScoreManager.UpdateScore(_playerA, _playerB, pointWinnerPlayerName);
                gameWinnerName = _gameScoreManager.GetGameWinnerName(_playerA, _playerB);
                if (gameWinnerName != "")
                {
                    break;
                }
            }

            _userInterface.ShowMessage($"{gameWinnerName} WINS THE GAME!!\n");
            return(gameWinnerName);
        }