Esempio n. 1
0
        public void StartGame()
        {
            OutputGenerator.FirstUserPrompt();
            while (_gameData.GetTurn() < _gameData.GetTurnLimit())
            {
                var currentUserInput = Console.ReadLine();
                if (currentUserInput == null)
                {
                    continue;
                }
                var errorCode = InputValidator.CheckInputForErrors(currentUserInput.ToLower().Trim(), _gameData.GetColoursPicked());

                if (errorCode == "valid")
                {
                    var currentGuess = InputFormatter(currentUserInput, _gameData.GetColoursPicked());
                    _gameData.SetCurrentColourList(currentGuess);

                    var result = CalculateResult();
                    if (ConvertStringArrayToString(result).Equals(ConvertStringArrayToString(_winningOutput)))
                    {
                        OutputGenerator.GenerateWin();
                        return;
                    }
                    _turnCounter++;
                    _gameData.SetTurn(_turnCounter);
                    OutputGenerator.PromptUser(result, _gameData.GetTurn());
                }
                else
                {
                    OutputGenerator.PromptUser(errorCode, _gameData.GetTurn());
                }
            }
            OutputGenerator.GenerateLoss(_gameData.GetTurnLimit());
        }