Esempio n. 1
0
        private void LoadNextRound()
        {
            Channel ch = client.GetChannel(_channellId);


            if (currentQuestion != null)
            {
                oldQuestions.Add(currentQuestion.Question);
            }

            currentQuestion = TriviaQuestionsPool.Instance.GetRandomQuestion(oldQuestions);

            if (currentQuestion == null || isQuit)
            {
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                ch.Send("Trivia bot stopping. :\\\n" + GetLeaderboard());
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                FinishGame();
                return;
            }
            Timer t = new Timer();
            t.Interval = 2500;
            t.Enabled  = true;
            t.Elapsed += async(s, ev) => {
                active = true;
                await ch.Send(currentQuestion.ToString());

                t.Enabled       = false;
                timeout.Enabled = true;//starting countdown of the next question
                stopwatch.Reset();
                stopwatch.Start();
            };
            return;
        }
Esempio n. 2
0
        private void LoadNextRound()
        {
            Channel ch = client.GetChannel(_channellId);
            

            if(currentQuestion!=null)
                oldQuestions.Add(currentQuestion.Question);

            currentQuestion = TriviaQuestionsPool.Instance.GetRandomQuestion(oldQuestions);

            if (currentQuestion == null || isQuit)
            {
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                ch.Send("Trivia bot stopping. :\\\n" + GetLeaderboard());
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                FinishGame();
                return;
            }
            Timer t = new Timer();
            t.Interval = 2500;
            t.Enabled = true;
            t.Elapsed += async (s, ev) => {
                active = true;
                await ch.Send(currentQuestion.ToString());
                t.Enabled = false;
                timeout.Enabled = true;//starting countdown of the next question
                stopwatch.Reset();
                stopwatch.Start();
            };
            return;
        }