/// <summary> /// Play game /// </summary> private static string playGame() { Words words = new Words(); Word pickedWord = words.Pick; PlayHangman playHangman = new PlayHangman(); playHangman.PickedWord = pickedWord; ConsoleKeyInfo yesNo = new ConsoleKeyInfo(); for (int i = 0; i < pickedWord.WordLength; i++) { Console.Write(" _ "); } Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); while (playHangman.Result() == GAMERESULT.CONTINUE) { Console.Write("Напиши букву --> "); ConsoleKeyInfo guessedLetter = Console.ReadKey(); if (playHangman.AddGuessedLetters(guessedLetter.KeyChar)) { playHangman.Play(); } } if (playHangman.Result() == GAMERESULT.LOSE) { Console.WriteLine("Вы проиграли :("); makeTextBlink("Загаданное слово было: '" + pickedWord.Content.ToUpper() + "'", 500); Console.WriteLine("Вы ходите сыграть еще раз ? Д/Н"); yesNo = Console.ReadKey(); return(yesNo.KeyChar.ToString()); } else { makeTextBlink("Вы выйграли !", 500); Console.WriteLine("Вы ходите сыграть еще раз ? Д/Н"); yesNo = Console.ReadKey(); return(yesNo.KeyChar.ToString()); } }
/// <summary> /// Play game /// </summary> private static string playGame() { Words words = new Words(); Word pickedWord = words.Pick; PlayHangman playHangman = new PlayHangman(); playHangman.PickedWord = pickedWord; ConsoleKeyInfo yesNo = new ConsoleKeyInfo(); for (int i = 0; i < pickedWord.WordLength; i++) { Console.Write(" _ "); } Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); while (playHangman.Result() == GAMERESULT.CONTINUE) { Console.Write("Pick a letter --> "); ConsoleKeyInfo guessedLetter = Console.ReadKey(); if (playHangman.AddGuessedLetters(guessedLetter.KeyChar)) { playHangman.Play(); } } if (playHangman.Result() == GAMERESULT.LOSE) { Console.WriteLine("So sorry. You struck out."); makeTextBlink("The mystery word was '" + pickedWord.Content.ToUpper() + "'", 500); Console.WriteLine("Do you want to play again ? Y/N"); yesNo = Console.ReadKey(); return(yesNo.KeyChar.ToString()); } else { makeTextBlink("You won !", 500); Console.WriteLine("Do you want to play again ? Y/N"); yesNo = Console.ReadKey(); return(yesNo.KeyChar.ToString()); } }