コード例 #1
0
    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);
    }
コード例 #2
0
        public async Task <ActionResult <TopicQuestion> > PostTopicQuestion(TopicQuestion topicQuestion)
        {
            _bll.TopicQuestions.Add(topicQuestion);
            await _bll.SaveChangesAsync();

            return(Ok(topicQuestion));
        }
コード例 #3
0
        public async Task <TopicQuestion> CreateTopicQuestion(TopicQuestion newTopicQuestion)
        {
            await _unitOfWork.TopicsQuestion
            .AddAsync(newTopicQuestion);

            await _unitOfWork.CommitAsync();

            return(newTopicQuestion);
        }
コード例 #4
0
        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));
        }
コード例 #5
0
 private void responseSelected(TopicQuestion response)
 {
     if (selectionCallback != null)
     {
         selectionCallback(response);
     }
     else
     {
         GameController.instance.TriggerEvent(response.trigger);
         UIChatMenu.Hide();
         _message.Discard();
     }
 }
コード例 #6
0
ファイル: Tagger.cs プロジェクト: ionutpasca/TrivialWiki
        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);
        }
コード例 #7
0
    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);
                }
            }
        }
    }
コード例 #8
0
        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;
            }
        }
コード例 #9
0
    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();
        }
    }
コード例 #10
0
 public async Task UpdateTopicQuestion(TopicQuestion topicQuestionToUpdate, TopicQuestion topicQuestion)
 {
     topicQuestionToUpdate.Topic = topicQuestion.Topic;
     await _unitOfWork.CommitAsync();
 }
コード例 #11
0
 public async Task DeleteTopicQuestion(TopicQuestion topicQuestion)
 {
     _unitOfWork.TopicsQuestion.Remove(topicQuestion);
     await _unitOfWork.CommitAsync();
 }