Ejemplo n.º 1
0
        //START BATTLE (reset)
        /// <summary>
        /// Sets up for a new trivia game
        /// </summary>
        /// <param name="pointsNeeded">The number of questions needed to win a trivia game.</param>
        /// <param name="turns">The number of turns in a trivia game</param>
        internal void StartTriviaGame(int pointsNeeded, int turns)
        {
            correctAnswersNeeded = pointsNeeded;
            correctAnswers       = 0;
            currentQuestion      = null;

            turnsLeft   = turns;
            triviaState = TriviaState.InProgress;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a triva object and
        /// loads a document full of Questions/answers and puts the data into question objects.
        /// </summary>
        internal Trivia(Random randyRandom)
        {
            string questionData = (string)TriviaResources.ResourceManager.GetObject("Questions");

            this.randyRandom = randyRandom;
            //Create questioncards and put them into a list
            using (StringReader reader = new StringReader(questionData))
            {
                this.PosibleQuestions = LoadQuestions(reader);
            }
            //set available questions to be equal to posible questions
            ResetQuestionList();
            this.currentQuestion = null;
            //creates a random object
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Set the current question to a new question
        /// and remove the last current question from the available question list.
        /// Used within trivia exclusivly.
        /// </summary>
        private void GetNewCurrentQuestion()
        {
            //If there is a current question, it is removed from the list of available questions
            if (currentQuestion != null)
            {
                AvailableQuestions.Remove(currentQuestion);
            }
            //Check to see if the AvailableQuestions is empty, and resets it if it is
            if (AvailableQuestions.Count <= 0)
            {
                ResetQuestionList();
            }
            //Gets a new current question
            int chosen = randyRandom.Next(AvailableQuestions.Count);

            currentQuestion = AvailableQuestions[chosen];
        }