Esempio n. 1
0
        public void InstantiateDialoguesFromDatabase()
        {
            {
                RelayTwo relay = new RelayTwo();
                relay.CreateTable(DialogueNode.TABLE_NAME);
                DialogueRunner runner = new DialogueRunner(relay, Language.SWEDISH);

                TimedDialogueNode d1 = runner.Create <TimedDialogueNode>("c", Language.SWEDISH, "d1") as TimedDialogueNode;
                d1.speaker = "A";

                TimedDialogueNode d2 = runner.Create <TimedDialogueNode>("c", Language.SWEDISH, "d2");
                d2.speaker = "B";

                relay.SaveAll("conversation.xml");
            }

            {
                RelayTwo relay = new RelayTwo();
                relay.LoadAll("conversation.xml");
                DialogueRunner runner = new DialogueRunner(relay, Language.SWEDISH);

                TimedDialogueNode d1 = runner.GetDialogueNode("c", "d1") as TimedDialogueNode;
                TimedDialogueNode d2 = runner.GetDialogueNode("c", "d2") as TimedDialogueNode;

                Assert.AreEqual("A", d1.speaker);
                Assert.AreEqual("B", d2.speaker);
            }
        }
Esempio n. 2
0
        public void SetupTingsThenSaveAndLoadFromDisk()
        {
            {
                TingRunner tingRunner = CreateTingRunnerWithSomeRoom();

                Animal bo = tingRunner.CreateTing <Animal>("Bo", new WorldCoordinate("SomeRoom", IntPoint.Zero));
                bo.species = "cow";
                bo.age     = 10;
                Animal howly = tingRunner.CreateTing <Animal>("Howly", new WorldCoordinate("SomeRoom", IntPoint.Zero));
                howly.species = "owl";

                Assert.AreEqual("cow", bo.species);
                Assert.AreEqual(10, bo.age);
                Assert.AreEqual("owl", howly.species);
                Assert.AreEqual(0, howly.age); // <- default value

                howly.age = 35;

                relay.SaveAll("farm.json");
            }

            {
                relay = new RelayTwo();
                relay.LoadAll("farm.json");
                TingRunner tingRunner = new TingRunner(relay, new RoomRunner(relay));

                Animal bo    = tingRunner.GetTing("Bo") as Animal;
                Animal howly = tingRunner.GetTing("Howly") as Animal;

                Assert.AreEqual("cow", bo.species);
                Assert.AreEqual(10, bo.age);
                Assert.AreEqual("owl", howly.species);
                Assert.AreEqual(35, howly.age);
            }
        }
Esempio n. 3
0
        public void InstantiateDialoguesFromDatabase()
        {
            {
                RelayTwo relay = new RelayTwo();
                relay.CreateTable(DialogueNode.TABLE_NAME);
                DialogueRunner runner = new DialogueRunner(relay, Language.SWEDISH);

                TimedDialogueNode d1 = runner.Create<TimedDialogueNode>("c", Language.SWEDISH, "d1") as TimedDialogueNode;
                d1.speaker = "A";

                TimedDialogueNode d2 = runner.Create<TimedDialogueNode>("c", Language.SWEDISH, "d2");
                d2.speaker = "B";

                relay.SaveAll("conversation.xml");
            }

            {
                RelayTwo relay = new RelayTwo();
                relay.LoadAll("conversation.xml");
                DialogueRunner runner = new DialogueRunner(relay, Language.SWEDISH);

                TimedDialogueNode d1 = runner.GetDialogueNode("c", "d1") as TimedDialogueNode;
                TimedDialogueNode d2 = runner.GetDialogueNode("c", "d2") as TimedDialogueNode;

                Assert.AreEqual("A", d1.speaker);
                Assert.AreEqual("B", d2.speaker);
            }
        }
        public void CreateAndSaveEmptyRelay()
        {
            InitialSaveFileCreator i = new InitialSaveFileCreator();
            RelayTwo emptyRelay      = i.CreateEmptyRelay();

            AssertThatCanFindAllTables(emptyRelay);
            emptyRelay.SaveAll("empty.json");
            emptyRelay.tables.Clear();
            emptyRelay.LoadAll("empty.json");
            AssertThatCanFindAllTables(emptyRelay);
        }
Esempio n. 5
0
        public void SetupTingsThenSaveAndLoadFromDisk()
        {
            {
                TingRunner tingRunner = CreateTingRunnerWithSomeRoom();

                Animal bo = tingRunner.CreateTing<Animal>("Bo", new WorldCoordinate("SomeRoom", IntPoint.Zero));
                bo.species = "cow";
                bo.age = 10;
                Animal howly = tingRunner.CreateTing<Animal>("Howly", new WorldCoordinate("SomeRoom", IntPoint.Zero));
                howly.species = "owl";

                Assert.AreEqual("cow", bo.species);
                Assert.AreEqual(10, bo.age);
                Assert.AreEqual("owl", howly.species);
                Assert.AreEqual(0, howly.age); // <- default value

                howly.age = 35;

                relay.SaveAll("farm.json");
            }

            {
                relay = new RelayTwo();
                relay.LoadAll("farm.json");
                TingRunner tingRunner = new TingRunner(relay, new RoomRunner(relay));

                Animal bo = tingRunner.GetTing("Bo") as Animal;
                Animal howly = tingRunner.GetTing("Howly") as Animal;

                Assert.AreEqual("cow", bo.species);
                Assert.AreEqual(10, bo.age);
                Assert.AreEqual("owl", howly.species);
                Assert.AreEqual(35, howly.age);
            }
        }