public void NextQuestion() { ++_currentQuestionIndex; if (_currentQuestionIndex < _questions.Length) { Debug.LogFormat("[ThreeSixNine] Next question\n{0}", CurrentQuestion.ToString()); _view.SetQuestion(_currentQuestionIndex, CurrentQuestion.Question, CurrentQuestion.PlayerQuestion, CurrentQuestion.Answer); } else { Debug.LogFormat("[ThreeSixNine] Next round"); GameManager.NextRound(); } }
private async Task StartGame() { while (!ShouldStopGame) { //reset the cancellation source TriviaCancelSource = new CancellationTokenSource(); var token = TriviaCancelSource.Token; //load question CurrentQuestion = TriviaQuestionPool.Instance.GetRandomQuestion(OldQuestions); if (CurrentQuestion == null) { await Channel.SendMessage("null").ConfigureAwait(false); await End().ConfigureAwait(false); return; } //add current question to the exclusion list OldQuestions.Add(CurrentQuestion); await Channel.SendMessage(CurrentQuestion.ToString()); //add PotentialGuess to OnMessageReceived Client.OnMessageRecieved += PotentialGuess; //allow people to guess GameActive = true; try { //hint await Task.Delay(HintTimeoutMilliseconds, token).ConfigureAwait(false); if (ShowHints) { await Channel.SendMessage("hint"); } await Task.Delay(QuestionDurationMilliseconds - HintTimeoutMilliseconds, token).ConfigureAwait(false); } catch (TaskCanceledException) { } GameActive = false; if (!TriviaCancelSource.IsCancellationRequested) { await Channel.SendMessage("correct answer was : asdf").ConfigureAwait(false); } } }
public async Task AskQuestion(SocketCommandContext context) { CurrentQuestion = Questions.Dequeue(); await context.Channel.SendMessageAsync(CurrentQuestion.ToString()); AcceptingAnswers = true; await Task.Delay(20 * 1000); await context.Channel.SendMessageAsync("10 seconds remain!"); await Task.Delay(10 * 1000); AcceptingAnswers = false; var sb = new StringBuilder(); //foreach (var result in CurrentQuestion) //{ // Players[result]++; // sb.AppendLine(result); //} await context.Channel.SendMessageAsync($"Round over!\n These players answered correctly:\n {sb}"); }