Beispiel #1
0
        private static void RunQuestion(TriviaQuestion question, int questionIndex, int questionCount, Player player, bool isMultiplayer)
        {
            Console.Clear();
            Console.WriteLine(Util.GetProgressBarText(questionIndex, questionCount));

            if (isMultiplayer)
            {
                Console.WriteLine($"It's {player.Name}'s turn now");
            }

            Console.WriteLine($"You are on Question {questionIndex + 1} out of {questionCount}");
            Console.WriteLine(question.Question);
            var multipleChoiceAnswers = new List <string>();

            multipleChoiceAnswers.AddRange(question.Incorrect);
            multipleChoiceAnswers.Add(question.Correct);
            Util.Shuffle(multipleChoiceAnswers);
            var userAnswer = Util.ReadAnswer(multipleChoiceAnswers);

            if (!userAnswer.HasValue)
            {
                return;
            }

            if (multipleChoiceAnswers[userAnswer.Value - 1] == question.Correct)
            {
                Console.WriteLine("Correct!");
                player.Score++;
            }
            else
            {
                Console.WriteLine($"Incorrect! {question.Correct} is the correct answer");
            }

            Util.PromptContinue();
        }