private void PlayRound(CurrentGameInfo CGI) { GetPlayerKey(CGI); _ui.ClearConsole(); _ui.WriteNumberList(CGI.PlayerSolution); _ui.WriteKeyList(CGI.KeyList); }
internal void StartNewGame() { CurrentGameInfo CGI = _modelBuilder.GetStartModel(); while (CGI.Tries > 0) { PlayRound(CGI); CGI = CheckForWin(CGI); } }
private void GetPlayerKey(CurrentGameInfo CGI) { CGI.PlayerSolution.Clear(); CGI.KeyList.Clear(); while (CGI.PlayerSolution.Count < 4) { PlayerInput(CGI); } CGI.KeyList = _gameLogic.GenerateKeyList(CGI); }
private void PlayerInput(CurrentGameInfo CGI) { int playerGuess; _ui.PlayerEnter(); Int32.TryParse(Console.ReadLine(), out playerGuess); bool valid = _gameLogic.Validate(playerGuess); if (valid) { _ui.ClearLine(); CGI.PlayerSolution.Add(playerGuess); } else { _ui.InvalidMessage(); } }
private CurrentGameInfo CheckForWin(CurrentGameInfo CGI) { bool result = CGI.PlayerSolution.SequenceEqual(CGI.Solution); if (result && CGI.Tries > 0) { _ui.Win(); CGI.Tries = 0; } else if (!result && CGI.Tries > 1) { CGI.Tries--; _ui.TryAgain(CGI.Tries); } else if (CGI.Tries == 1) { _ui.Loser(CGI.Solution); CGI.Tries = 0; } return(CGI); }