コード例 #1
0
        public static void ConversationRunner(IConversation conversation)
        {
            IEnumerable<IDialog> currentDialogs = conversation.CurrentDialogs().ToList();

            Console.WriteLine(conversation.GetDescription());
            Console.WriteLine("");
            Console.WriteLine("----------------------------");

            while (currentDialogs.Any())
            {
                if (currentDialogs.Count() == 1)
                {
                    Console.WriteLine("-" + currentDialogs.First().GetText());
                    Console.ReadKey();
                    conversation.Next();
                }
                else if (currentDialogs.Count() > 1)
                {
                    Console.WriteLine("(Select an answer) 1-"+currentDialogs.Count()+")");
                    int i = 1;
                    foreach (var dialog in currentDialogs)
                    {
                        Console.WriteLine("    "+i+")"+dialog.GetText());
                        i++;
                    }

                    int answer = ReadAnswerNumber(1, currentDialogs.Count());

                    conversation.Answer(currentDialogs.ToList()[answer-1]);
                }

                currentDialogs = conversation.CurrentDialogs();
            }
        }
コード例 #2
0
        public static void ConversationRunner(IConversation conversation)
        {
            IEnumerable <IDialog> currentDialogs = conversation.CurrentDialogs().ToList();

            Console.WriteLine(conversation.GetDescription());
            Console.WriteLine("");
            Console.WriteLine("----------------------------");

            while (currentDialogs.Any())
            {
                if (currentDialogs.Count() == 1)
                {
                    Console.WriteLine("-" + currentDialogs.First().GetText());
                    Console.ReadKey();
                    conversation.Next();
                }
                else if (currentDialogs.Count() > 1)
                {
                    Console.WriteLine("(Select an answer) 1-" + currentDialogs.Count() + ")");
                    int i = 1;
                    foreach (var dialog in currentDialogs)
                    {
                        Console.WriteLine("    " + i + ")" + dialog.GetText());
                        i++;
                    }

                    int answer = ReadAnswerNumber(1, currentDialogs.Count());

                    conversation.Answer(currentDialogs.ToList()[answer - 1]);
                }

                currentDialogs = conversation.CurrentDialogs();
            }
        }
コード例 #3
0
        public void If_Start_Is_Branched_Get_Available_Dialogs()
        {
            conversation.SetStartDialog(new[] { dialog1, dialog2 }.ToList());

            Assert.AreEqual(2, conversation.CurrentDialogs().Count());
        }
コード例 #4
0
        public void Should_Set_Start()
        {
            conversation.SetStartDialog(new[] { dialog1 }.ToList());

            Assert.AreEqual(dialog1, conversation.CurrentDialogs().First());
        }