public void Play(string[] initialColors) { var thereIsNoWinner = true; while (thereIsNoWinner) { var userColors = _userColorsProvider.ProvideColors(); var hintsProvider = new HintsProvider(); var hints = hintsProvider.GiveHints(userColors, initialColors); _counter++; foreach (var hint in hints) { _communicationOperations.WriteLine(hint); } if (_counter == MaxTries) { _communicationOperations.WriteLine("You lost. Only 60 attempts allowed."); break; } if (hints.Count == 4) { _communicationOperations.WriteLine("You won! Congratulations :)"); thereIsNoWinner = false; } } }
private string GetUserInput() { _communicationOperations.WriteLine( "Type 4 colors from this range: Red, Blue, Green, Orange, Purple, Yellow, separated with a coma: ','"); var input = _communicationOperations.Read(); return(input); }
public int[,] GetGridState() { _communicationOperations.WriteLine("Provide initial cell state in the following format:' 0010,1000,1100,000 ' where 1 mean the cell is alive and 0 means cell is dead. "); var userAnswer = _communicationOperations.Read(); var userAnswerArray = userAnswer.Split(',').ToArray(); var userAnswerAsTwoDArray = new int[userAnswerArray.Length, userAnswerArray.Length]; for (var i = 0; i < userAnswerArray.Length; i++) { for (var j = 0; j < userAnswerArray[i].Length; j++) { userAnswerAsTwoDArray[i, j] = int.Parse(userAnswerArray[i][j].ToString()); } } return(userAnswerAsTwoDArray); }
public void PrintGrid() { _communicationOperations.Clear(); _communicationOperations.WriteLine(StringFormatter.Format(_grid)); }