public void TrySavingComputerMemory() { string saveName = "ComputerMemoryTest.json"; { WorldTestHelper.GenerateInitData (); InitialSaveFileCreator i = new InitialSaveFileCreator (); World world = new World (i.CreateRelay (WorldTestHelper.INIT_DATA_PATH)); Memory computerMemory = world.tingRunner.CreateTing<Memory> ("ComputerMemory1", new TingTing.WorldCoordinate ("Eden", 2, 3)); computerMemory["a"] = 42; computerMemory["b"] = 100.5; world.Save (saveName); } { World world = new World (saveName); Memory computerMemory = world.tingRunner.GetTing<Memory> ("ComputerMemory1"); Assert.AreEqual (2, computerMemory.data.Keys.Count); Assert.AreEqual (42, computerMemory["a"]); Assert.AreEqual (100.5, computerMemory["b"]); } }
public void LoadAndSaveDialogueDuplicationBug() { string saveName = "../Saves/step1_save.json"; var outputDialogue = new List<string>(); Console.WriteLine("STEP 1"); // Step 1 { InitialSaveFileCreator i = new InitialSaveFileCreator(); var world1 = new World(i.CreateRelay(WorldTestHelper.INIT_DATA_PATH)); WorldTestHelper.PreloadWorld(world1); GameTypes.D.onDLog += Console.WriteLine; world1.dialogueRunner.logger.AddListener(Console.WriteLine); world1.dialogueRunner.AddOnSomeoneSaidSomethingListener(o => { Console.WriteLine(o.speaker + ": " + o.line); outputDialogue.Add(o.line); }); WorldTestHelper.UpdateWorld(world1, 1f); PrintActiveStuff(world1); world1.dialogueRunner.RunStringAsFunction("Story(BeforeFirst)"); WorldTestHelper.UpdateWorld(world1, 1f); PrintActiveStuff(world1); world1.dialogueRunner.RunStringAsFunction("Story(First)"); WorldTestHelper.UpdateWorld(world1, 0.5f); PrintActiveStuff(world1); world1.dialogueRunner.EventHappened("DO_IT_REAL_GOOD"); PrintActiveStuff(world1); WorldTestHelper.UpdateWorld(world1, 3f); world1.Save(saveName); GameTypes.D.onDLog -= Console.WriteLine; } Console.WriteLine("\n\nSTEP 2"); // Step 2 { var world2 = new World(saveName); WorldTestHelper.PreloadWorld(world2); world2.dialogueRunner.logger.AddListener(Console.WriteLine); GameTypes.D.onDLog += Console.WriteLine; world2.dialogueRunner.AddOnSomeoneSaidSomethingListener(o => { Console.WriteLine(o.speaker + ": " + o.line); outputDialogue.Add(o.line); }); PrintActiveStuff(world2); WorldTestHelper.UpdateWorld(world2, 3f); PrintActiveStuff(world2); world2.dialogueRunner.RunStringAsFunction("Story(Second)"); WorldTestHelper.UpdateWorld(world2, 3.0f); PrintActiveStuff(world2); world2.dialogueRunner.EventHappened("DO_IT_REAL_GOOD"); WorldTestHelper.UpdateWorld(world2, 3f); } }