public void Run(String tome, Action postExecution = null)
    {
        conv  = ConversationLoader.CreateConversation(tome);
        state = State.Update;

        // activate itself so it can start running
        gameObject.SetActive(true);

        if (postExecution != null)
        {
            this.postExecution = postExecution;
        }
    }
Ejemplo n.º 2
0
        public void Traverse_TomeTest3_WithChoice2_UsingBakedInBranches()
        {
            int[] choices = new int[] { 2 };
            var   conv    = ConversationLoader.CreateConversation(Path.Combine(Config.TomePath, "TomeTest_3.yml"));

            string result   = TraverseGraph(conv, choices);
            string expected = "Diana: I didn't want to be the one to forget\n" +
                              "Diego: I thought of everything I'd never regret\n" +
                              "2: I don't believe in him - his lips on the ground\n" +
                              "Diana: But no one gives us time anymore\n" +
                              "Diego: Will you be my light?\n";

            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 3
0
        public void Traverse_TomeTest6_Choice2_CheckingPassingSelection()
        {
            //avegers assemble
            int[] choices = new int[] { 2 };
            var   conv    = ConversationLoader.CreateConversation(Path.Combine(Config.TomePath, "TomeTest_6.yml"));

            //act
            string result   = TraverseGraph(conv, choices);
            string expected = "Spongebob: I'm ready\n" +
                              "2: Path 3\n" +
                              "Sandy: Karate chop\n";

            //assert
            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 4
0
        public void Traverse_TomeTest5_Choice1_CheckingForBlockSkipping()
        {
            int[] choices = new int[] { 1 };
            var   conv    = ConversationLoader.CreateConversation(Path.Combine(Config.TomePath, "TomeTest_5.yml"));

            // action
            string result   = TraverseGraph(conv, choices);
            string expected = "1: choice 2\n" +
                              "Other: Another one\n" +
                              "Other: something\n" +
                              "Other: done\n" +
                              "Last: Hey\n";

            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 5
0
        public void Traverse_TomeTest4_Choice1_CheckingForFlagRequirements()
        {
            // assemble
            int[] choices = new int[] { 1 };
            var   conv    = ConversationLoader.CreateConversation(Path.Combine(Config.TomePath, "TomeTest_4.yml"));

            // action
            string result   = TraverseGraph(conv, choices);
            string expected = "Diego: Hey what's happening\n" +
                              "1: This sets two to true\n" +
                              "Person: Hey\n" +
                              "Person: Blah\n";

            // assert
            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 6
0
        public void Traverse_TomeTest2_WithChoice0()
        {
            // arrange
            int[] choices = new int[] { 0 };
            var   conv    = ConversationLoader.CreateConversation(Path.Combine(Config.TomePath, "TomeTest_2.yml"));

            // act
            string result   = TraverseGraph(conv, choices);
            string expected = "Yulia: What the f**k is this\n" +
                              "Yulia: What are you doing?\n" +
                              "0: Nothing\n" +
                              "Yulia: You're lying\n" +
                              "Diego: Yeah she is\n" +
                              "Diego: There's a lot of yelling going on right now\n";

            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 7
0
        public void Traverse_TomeTest6_Choice1_CheckingBakedInBranchSelection()
        {
            //assemble
            int[] choices = new int[] { 1 };
            var   conv    = ConversationLoader.CreateConversation(Path.Combine(Config.TomePath, "TomeTest_6.yml"));

            //act
            string result   = TraverseGraph(conv, choices);
            string expected = "Spongebob: I'm ready\n" +
                              "1: Path 2\n" +
                              "Squidward: Arghhh\n" +
                              "Patrick: SPONGEBOB\n" +
                              "Sandy: Karate chop\n";

            //assert
            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 8
0
        public void Traverse_TomeTest6_Choice0_CheckingBranchNameSelection()
        {
            //assemble
            int[] choices = new int[] { 0 };
            var   conv    = ConversationLoader.CreateConversation(Path.Combine(Config.TomePath, "TomeTest_6.yml"));

            //act
            string result   = TraverseGraph(conv, choices);
            string expected = "Spongebob: I'm ready\n" +
                              "0: Path 1\n" +
                              "Pearl: Daddy!\n" +
                              "Sandy: Karate chop\n" +
                              "Mr.Krabs: I like money\n";

            //assert
            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 9
0
        public void Traverse_TomeTest5_Choice0_CheckingForMixedFlagRequirements()
        {
            int[] choices = new int[] { 0 };
            var   conv    = ConversationLoader.CreateConversation(Path.Combine(Config.TomePath, "TomeTest_5.yml"));

            //action
            string result   = TraverseGraph(conv, choices);
            string expected = "0: choice 1\n" +
                              "Person: hello\n" +
                              "Person: how\n" +
                              "Person: are you\n" +
                              "Other: Another one\n" +
                              "Other: done\n" +
                              "More: Blah\n" +
                              "Last: Hey\n";

            Assert.AreEqual(expected, result);
        }
Ejemplo n.º 10
0
        public override int Run(string[] remainingArguments)
        {
            try
            {
                var pathToFile = Path.Combine(Directory.GetCurrentDirectory(), FileName);
                // does not need to save anything just needs to parse it
                ConversationLoader.CreateConversation(pathToFile);
                Console.Out.WriteLine(FileName + " parsed correctly.");
                return(0);
            }
            catch (Exception ex)
            {
                // change this with some better exception handling
                Console.Error.WriteLine(ex.Message);
                Console.Error.WriteLine(ex.StackTrace);

                return(1);
            }
        }
Ejemplo n.º 11
0
        public override int Run(string[] remainingArguments)
        {
            try
            {
                string pathToFile = Path.Combine(Directory.GetCurrentDirectory(), FileName);
                var    graph      = ConversationLoader.CreateConversation(pathToFile);
                var    runner     = new Traverser(graph);
                runner.Traverse();

                // success
                return(0);
            }
            catch (Exception e)
            {
                Console.Error.Write(e.Message);
                Console.Error.Write(e.StackTrace);

                // errorrrr
                return(1);
            }
        }
Ejemplo n.º 12
0
        public void Traverse_TomeTest3_WithChoice0_UsingBranchName()
        {
            // These are inputs, for the traversal
            // for descisions these correspond to the chosen choice not the branch
            // assemble
            int[] choices = new int[] { 0 };
            var   conv    = ConversationLoader.CreateConversation(Path.Combine(Config.TomePath, "TomeTest_3.yml"));

            // action
            string result   = TraverseGraph(conv, choices);
            string expected = "Diana: I didn't want to be the one to forget\n" +
                              "Diego: I thought of everything I'd never regret\n" +
                              "0: A little time with you is all that I get\n" +
                              "Diego: I gotta be in your arms baby\n" +
                              "Diego: But far away I seek for your light\n" +
                              "Diego: I hold on because for you my heart keeps beating\n" +
                              "Diana: But no one gives us time anymore\n" +
                              "Diego: Will you be my light?\n";

            // assert
            Assert.AreEqual(expected, result);
        }