private async Task State_SwitchCategory(IDialogContext context, IMessageActivity message, LuisResult luis) { bool firstTime = false; if (CurrentState != BotState.SwitchCategory) { firstTime = true; CurrentState = BotState.SwitchCategory; } // See if the category was provided with the SwitchCategory intent var categoryValue = GetCategoryFromLuis(luis); if (categoryValue == TriviaCategory.None) { categoryValue = GetCategoryValue(message.Text); } if (categoryValue != TriviaCategory.None) { Category = categoryValue; await Responses.Send_SwitchedCategory(context, message, Category); await Trivia_AskQuestion(context, message, true); return; } if (!firstTime) { await Responses.Send_DidNotUnderstand(context, message); } await Responses.AskForCategory(context, message); }
public void Deconstruct(out int?Amount, out TriviaCategory Category, out Difficulty Difficulty, out bool?MultipleChoice) { Amount = this.Amount; Category = this.Category; Difficulty = this.Difficulty; MultipleChoice = this.MultipleChoice; }
public TriviaQuestion(int questionID, string question, string correctAnswer, string wrongAnswer1, string wrongAnswer2, string wrongAnswer3, TriviaCategory category) { QuestionID = questionID; Question = question; CorrectAnswer = correctAnswer; WrongAnswer1 = wrongAnswer1; WrongAnswer2 = wrongAnswer2; WrongAnswer3 = wrongAnswer3; TriviaCategory = category; HasBeenAsked = false; }
private void ResetState() { CurrentState = BotState.None; Category = TriviaCategory.None; ExpectedAnswer = null; AnswerOptions = null; CurrentQuestion = null; ChosenAnswer = null; ConfirmingAnswer = false; TimedOutLastTime = false; }
private void OnGUI() { foreach (Monster monster in _inventoryManager.Monsters) { TriviaCategory category = monster.TriviaCategory; Image image = transform.Find(category.ToString()).GetComponent <Image>(); switch (category) { case TriviaCategory.ArtsAndLiterature: image.sprite = ArtsAndLiteratureSprite; break; case TriviaCategory.Entertainment: image.sprite = EntertainmentSprite; break; case TriviaCategory.Geography: image.sprite = GeographySprite; break; case TriviaCategory.GeneralKnowledge: image.sprite = GeneralKnowledgeSprite; break; case TriviaCategory.History: image.sprite = HistorySprite; break; case TriviaCategory.ScienceAndNature: image.sprite = ScienceAndNatureSprite; break; case TriviaCategory.SportsAndLeisure: image.sprite = SportsAndLeisureSprite; break; } } }
public int PickAQuestion_Category(TriviaCategory category) { //get a list of questions int totalQuestions = _repo.GetQuestionCount(); Random randy = new Random(); int questionToAsk = randy.Next(1, totalQuestions + 1); int counter = 0; while (_repo.HasItBeenAsked(questionToAsk) || _repo.GetQuestionById(questionToAsk).TriviaCategory != category) { questionToAsk = randy.Next(1, totalQuestions + 1); if (counter > 101) { Console.WriteLine("No More available Questions. Try Reloading the game."); Console.ReadKey(); keepPlaying = false; return(-1); } counter++; } return(questionToAsk); }
// Process information sent with the LUIS intent Play private async Task ProcessLuis_Play(IDialogContext context, IMessageActivity message, LuisResult luis) { var categoryValue = GetCategoryFromLuis(luis); if (categoryValue != TriviaCategory.None) { await Responses.Send_PlayingCategory(context, message, categoryValue); Category = categoryValue; } if (luis?.Entities != null) { var mode = from entity in luis.Entities where entity.Type.NormalizedEquals("mode") select entity; if (mode?.Count() > 0) { await Responses.Send_LightningModeStart(context, message); } } }
/// <summary> /// Gets the statistics for the specified <paramref name="category"/> asynchronously. /// </summary> /// <param name="category">the category to get the questions for</param> /// <param name="cancellationToken"> /// a cancellation token used to propagate notification that the asynchronous operation /// should be canceled. /// </param> /// <returns> /// a task that represents the asynchronous operation. The task result is the response /// received from the Trivia API endpoint. /// </returns> public Task <CategoryStatisticsResponse> GetStatisticsAsync(TriviaCategory category, CancellationToken cancellationToken = default) => GetStatisticsAsync(category.Id, cancellationToken);
public async static Task Send_SwitchedCategory(IDialogContext context, IMessageActivity message, TriviaCategory category) { var replyText = $"You've switched to the category \"{category.DisplayName()}\""; var reply = CreateResponse( context, message, replyText, replyText, messageType: MessageType.Statement, inputHint: InputHints.IgnoringInput); await context.PostAsync(reply); }
public async static Task Send_PlayingCategory(IDialogContext context, IMessageActivity message, TriviaCategory category) { var replyText = SelectRandomString(new string[] { $"We're playing: \"{category.DisplayName()}\".", $"We're going with: \"{category.DisplayName()}\" today.", $"You'll get questions about: \"{category.DisplayName()}\"." }); var reply = CreateResponse( context, message, replyText, replyText, messageType: MessageType.Statement, inputHint: InputHints.IgnoringInput); await context.PostAsync(reply); }