internal static TopicQuestion Create(Talker talker, Topic topic) { TopicQuestion result = new TopicQuestion(); result.message = topic.questionMessage; result.topicId = topic.id; result.trigger = string.Empty; if (talker.HasCustomQuestion(topic)) { TopicQuestion customQuestion = talker.GetCustomQuestion(topic); if (!string.IsNullOrEmpty(customQuestion.message)) { result.message = customQuestion.message; } if (customQuestion.trigger != null) { result.trigger = customQuestion.trigger; } } return(result); }
public async Task <ActionResult <TopicQuestion> > PostTopicQuestion(TopicQuestion topicQuestion) { _bll.TopicQuestions.Add(topicQuestion); await _bll.SaveChangesAsync(); return(Ok(topicQuestion)); }
public async Task <TopicQuestion> CreateTopicQuestion(TopicQuestion newTopicQuestion) { await _unitOfWork.TopicsQuestion .AddAsync(newTopicQuestion); await _unitOfWork.CommitAsync(); return(newTopicQuestion); }
public async Task <ActionResult <TopicQuestion> > PutTopicQuestion(Guid id, TopicQuestion topicQuestion) { if (id != topicQuestion.Id) { return(BadRequest()); } await _bll.TopicQuestions.UpdateAsync(topicQuestion); await _bll.SaveChangesAsync(); return(Ok(topicQuestion)); }
private void responseSelected(TopicQuestion response) { if (selectionCallback != null) { selectionCallback(response); } else { GameController.instance.TriggerEvent(response.trigger); UIChatMenu.Hide(); _message.Discard(); } }
public void GenerateQuestions(string topic) { topic = topic.Replace(" ", "_"); var outputJsonPath = DirectoryManager.GetOutputJsonPath(topic); var tpr = new TextProcessing(); var resultList = tpr.GetSentencesInformationFromJson(outputJsonPath); var questionList = new List <TopicQuestion>(); foreach (var sentence in resultList) { var dependencies = GetSentenceDependency(sentence); var words = GetSentenceWords(sentence); var sentenceInfo = new SentenceInformationDto(sentence.SentenceText, dependencies, words); if (MustContinue(sentence, sentenceInfo)) { continue; } GeneratedQuestion generatedQuestion; try { generatedQuestion = QuestionGenerator.Generate(sentenceInfo); } catch { continue; } if (string.IsNullOrEmpty(generatedQuestion?.Question)) { continue; } var cleanQuestion = QuestionCleaner.RemovePunctuationFromEnd(generatedQuestion.Question); cleanQuestion = $"{cleanQuestion}?"; var question = new TopicQuestion { Topic = topic, InitialSentence = sentence.SentenceText, Question = cleanQuestion, Answer = generatedQuestion.Answer }; questionList.Add(question); } DirectoryManager.WriteQuestionsToFile(questionList, topic); }
public override void UpdateEvent() { if (selectedEvent != null && !selectedEvent.IsEventComplete()) { selectedEvent.UpdateEvent(); return; } if (chatMessage == null) { if (target != null) { Talker talker = target.GetComponent <Talker>(); if (talker != null) { Topic[] talkerTopics = NeverdawnDatabase.GetTopics(talker.topicIds, true); Topic[] talkTopics = PlayerJournal.GetCommonTopics(talkerTopics); TopicQuestion[] questions = new TopicQuestion[talkTopics.Length + 1]; for (int i = 0; i < talkTopics.Length; i++) { questions[i] = TopicQuestion.Create(talker, talkTopics[i]); } questions[questions.Length - 1] = new TopicQuestion() { message = "That'll be all.", trigger = null }; chatMessage = new QuestionMessage(getTargetSelf(0).identity.icon, string.Empty, questions); UIChatMenu.SendQuestionMessage(chatMessage, questionSelected); } } } }
public void LoadView(ViewType typeView) { switch (typeView) { case ViewType.Main: StartPage view = new StartPage(); VMStartPage vm = new VMStartPage(this); LoadUserControl(view, vm); break; case ViewType.Setting: SettingOfPlay page = new SettingOfPlay(); VMSetting modal = new VMSetting(this); LoadUserControl(page, modal); break; case ViewType.ChooseStage: SubStages choose = new SubStages(); VMSubStages modalch = new VMSubStages(this); choose.ActionEvent += modalch.HandleImage; LoadUserControl(choose, modalch); break; case ViewType.PLay: TopicQuestion play = new TopicQuestion(); VMTopicQuestion modalpl = new VMTopicQuestion(this); play.KeyDown += modalpl.HandleKeyPress; LoadUserControl(play, modalpl); break; case ViewType.Thems: ThemsQuation thems = new ThemsQuation(); VMQuestionThems modalth = new VMQuestionThems(this); thems.EventImage += modalth.HandleImage; LoadUserControl(thems, modalth); break; } }
private void questionSelected(TopicQuestion question) { if (question.trigger == null) { chatMessage.Discard(); } else { chatMessage = null; if (question.trigger.Equals(string.Empty)) { Topic topic = NeverdawnDatabase.GetTopic(question.topicId); selectedEvent = topic.defaultEvent; } else { selectedEvent = EventController.FindEvent(question.trigger); } selectedEvent.ResetEvent(); } }
public async Task UpdateTopicQuestion(TopicQuestion topicQuestionToUpdate, TopicQuestion topicQuestion) { topicQuestionToUpdate.Topic = topicQuestion.Topic; await _unitOfWork.CommitAsync(); }
public async Task DeleteTopicQuestion(TopicQuestion topicQuestion) { _unitOfWork.TopicsQuestion.Remove(topicQuestion); await _unitOfWork.CommitAsync(); }