private void UpdateUI() { UpdateAttemptsLeft(); if (_backend.IsGameWon()) { ResetGame(); MessageBox.Show("Congratulations. You won!"); } else if (_backend.IsGameOver()) { ResetGame(); MessageBox.Show("Awww. You lost.."); } string word = _backend.GetWord(); string[] guessedChars = _backend.GetGuesses(); string wordUI = ""; foreach (var c in word) { if (guessedChars.Any(s => s.Equals(c.ToString()))) { wordUI += " " + c; } else { wordUI += " _"; } } labelWord.Content = wordUI; UpdatePicture(); }
private void buttonStartGame_Click(object sender, RoutedEventArgs e) { _backend = new Backend(); var scenario = GenerateScenario(); _backend.Setup(scenario.Item1, scenario.Item2); string word = _backend.GetWord(); string wordUI = ""; foreach (var c in word) { wordUI += " _"; } labelWord.Content = wordUI; UpdateAttemptsLeft(); _gameRunning = true; }