示例#1
0
        void Start()
        {
            string[]  words     = ReadWords();
            string    lingoWord = ChooseWord(words);
            LingoGame lingoGame = new LingoGame();

            lingoGame.Init(lingoWord);

            PlayLingo(lingoGame);
        }
示例#2
0
        } //Ask the player to enter a word

        void DisplayResult(LingoGame lingoGame) //Show what letters the player guessed right
        {
            for (int i = 0; i < WORDLENGTH; i++)
            {
                if (lingoGame.letterResults[i] == Enums.LetterState.Correct)
                {
                    Console.BackgroundColor = ConsoleColor.DarkGreen;
                }
                else if (lingoGame.letterResults[i] == Enums.LetterState.WrongPos)
                {
                    Console.BackgroundColor = ConsoleColor.DarkYellow;
                }

                Console.Write(lingoGame.playerWord[i]);

                Console.ResetColor();
            }

            Console.WriteLine();
        }
示例#3
0
        void PlayLingo(LingoGame lingoGame)
        {
            int attemptsLeft = ATTEMPTS;

            while (attemptsLeft > 0 && !lingoGame.GuessedWord())
            {
                string playerWord = ReadPlayerWord(WORDLENGTH);

                lingoGame.CheckWord(playerWord);
                DisplayResult(lingoGame);

                attemptsLeft--;
            }

            if (lingoGame.GuessedWord())
            {
                Console.WriteLine("Congrats!");
            }
            else
            {
                Console.WriteLine("You loose!!!");
            }
        } //Play a game of lingo