private void MainThemeDiscussing(string userInput) { string keyPhrase = _phrases.MainPhrases.Keys.FirstOrDefault(phrase => userInput.ToLower().Contains(phrase.ToLower())); string meaningPhrase = meaningDictionary.Keys.FirstOrDefault(phrase => userInput.ToLower().Contains(phrase.ToLower())); if (keyPhrase != null) { DiscussMainPhrase(keyPhrase); } else if (meaningPhrase != null) { BragOfKnowledge(meaningPhrase); } else { int choice = additionalRandomizer.DiscrDistr(); if (dynamicPhrasesList.Count < 1) { choice = random.Next(2, 3); } switch (choice) { //Generate result from dynamicPhrasesList case 1: { Console.Write("Бот: "); TypingHelper.TypeString(TakeRandomItem(dynamicPhrasesList)); break; } //Ask meaning of the any word case 2: { AskMeaningOfSomeWord(userInput); break; } //Continue dialog case 3: { Console.Write("Бот: "); TypingHelper.TypeString(TakeRandomItem(_phrases.CountinuingPhrases)); break; } } } }
private void DiscussMainPhrase(string userInput) { Console.Write("Бот: "); TypingHelper.TypeString(_phrases.MainPhrases[userInput].ElementAt(0)); dynamicPhrasesList.Add(_phrases.MainPhrases[userInput].ElementAt(1)); }
private void BragOfKnowledge(string meaningPhrase) { Console.Write("Бот: "); TypingHelper.TypeString($"Позволь похвастаться новыми знаниями) Я знаю, что {meaningPhrase} - {meaningDictionary[meaningPhrase]}"); }