Пример #1
0
        bool Start()
        {
            LingoGame lingoGame = new LingoGame();

            lingoGame.Init();
            Console.Clear();
            PlayLingo(lingoGame);

            return(ProgramTools.LoopProgram());
        }
Пример #2
0
        string ReadPlayerWord(LingoGame lingoGame)
        {
            string playerWord = ReadTools.ReadString($"Enter a ({lingoGame.lingoWord.Length}-letter) word, attempt {lingoGame.attempt}: ");

            while (playerWord.Length != lingoGame.lingoWord.Length)
            {
                Console.WriteLine($"'{playerWord}' is not a {lingoGame.lingoWord.Length}-letter word.");
                playerWord = ReadTools.ReadString($"Enter a ({lingoGame.lingoWord.Length}-letter) word, attempt {lingoGame.attempt}: ");
            }
            return(playerWord);
        }
Пример #3
0
 void DisplayResults(LingoGame lingoGame)
 {
     for (int i = 0; i < lingoGame.lingoWord.Length; i++)
     {
         if (lingoGame.letterResults[i] == LetterState.Correct)
         {
             Console.BackgroundColor = ConsoleColor.DarkGreen;
         }
         else if (lingoGame.letterResults[i] == LetterState.WrongPosition)
         {
             Console.BackgroundColor = ConsoleColor.DarkYellow;
         }
         Console.Write(lingoGame.playerWord[i]);
         Console.ResetColor();
     }
     Console.WriteLine();
 }
Пример #4
0
 void PlayLingo(LingoGame lingoGame)
 {
     while (lingoGame.attempt <= 5 && !lingoGame.GuessedWord())
     {
         string playerWord = ReadPlayerWord(lingoGame);
         lingoGame.CheckWord(playerWord);
         DisplayResults(lingoGame);
     }
     if (lingoGame.GuessedWord())
     {
         Console.WriteLine("You have guessed the word!");
     }
     else
     {
         Console.WriteLine("You didn't guess the word in time...");
         Console.WriteLine($"The correct word was: {lingoGame.lingoWord}.");
     }
 }