public void CallPrintWithHugeNegativeNumber() { MimanPathfinder2.ClearRoomNetwork(); var computer = _world.tingRunner.CreateTing <Computer> ("Computer", testDefaultCoordinate); computer.masterProgramName = "BlankSlate"; computer.masterProgram.sourceCodeContent = @" Print(-999999) Print(-999999999999999999999) Print(999999999999999999999) " ; computer.PrepareForBeingHacked(); computer.masterProgram.Compile(); PrintErrors(computer.masterProgram); WorldTestHelper.UpdateWorld(_world, 1f); //string msg = null; //D.onDLog += (pMessage) => msg = pMessage; computer.masterProgram.Start(); WorldTestHelper.UpdateWorld(_world, 1f); PrintErrors(computer.masterProgram); Assert.IsFalse(computer.containsBrokenPrograms); Assert.AreEqual("-999999", computer.consoleOutput[0]); }
public void HackdevAllowFunction() { MimanPathfinder2.ClearRoomNetwork(); var h = _world.tingRunner.CreateTing <Hackdev> ("Hackdev", testDefaultCoordinate); h.masterProgramName = "BlankSlate"; h.masterProgram.sourceCodeContent = @" bool Allow(string target, number level) Log('calling allow, level: ' + level) return level == 0 end " ; h.PrepareForBeingHacked(); h.masterProgram.Compile(); PrintErrors(h.masterProgram); WorldTestHelper.UpdateWorld(_world, 3.0f); string msg = null; D.onDLog += (pMessage) => msg = pMessage; h.masterProgram.StartAtFunctionIfItExists("BLAHAHAHAHA", new object[] { "blah", 10 }, null); h.masterProgram.StartAtFunction("Allow", new object[] { "blah", 10 }, null); WorldTestHelper.UpdateWorld(_world, 1f); Assert.AreEqual("LOG: calling allow, level: 10", msg); Assert.IsTrue(h.masterProgram.HasFunction("Allow", true)); }
public void WalkThroughSeveralRoomsToInteractWithSomethingAtTheEnd() { MimanPathfinder2.ClearRoomNetwork(); _adam.logger.AddListener(Console.WriteLine); SmartWalkBehaviour.s_logger.AddListener(Console.WriteLine); /* * _adam.AddDataListener<Character.WalkMode>("walkMode", ((Character.WalkMode prev, Character.WalkMode newWalkMode) => { * //throw new Exception("NEW WALK MODE: " + newWalkMode); * Console.WriteLine("NEW WALK MODE: " + newWalkMode); * })); */ _adam.position = new WorldCoordinate("Eden", 0, 4); MysticalCube cube = _world.tingRunner.GetTing <MysticalCube>("PowerCube"); cube.position = new WorldCoordinate("Kitchen", 3, 3); _adam.WalkToTingAndInteract(cube); WorldTestHelper.UpdateWorld(_world, 60f); Assert.AreEqual(cube, _adam.handItem); }
public void PathfindToOtherRoom() { MimanPathfinder2.ClearRoomNetwork(); //D.onDLog += Console.WriteLine; // take care of the D.Log message from invalid path _eva.logger.AddListener(Console.WriteLine); SimpleRoomBuilder srb = new SimpleRoomBuilder(_world.roomRunner); srb.CreateRoomWithSize("DistantRoom", 10, 10); var p1 = _world.tingRunner.CreateTing <Point>("p1", new WorldCoordinate("Eden", new IntPoint(2, 4))); var p2 = _world.tingRunner.CreateTing <Point>("p2", new WorldCoordinate("DistantRoom", new IntPoint(4, 4))); // Add doors var door1 = _world.tingRunner.CreateTing <Door>("Door1", new WorldCoordinate("Eden", new IntPoint(4, 4))); _world.tingRunner.CreateTing <Door>("Door2", new WorldCoordinate("DistantRoom", new IntPoint(3, 4))); door1.targetDoorName = "Door2"; var pathfinder = new MimanPathfinder2(_world.tingRunner, _world.roomRunner); var result = pathfinder.Search(p1, p2); Assert.AreEqual(MimanPathStatus.FOUND_GOAL, result.status); Assert.AreEqual(1, result.tings.Length); Assert.AreEqual(door1, result.tings[0]); Console.WriteLine("RESULT: " + result.ToString()); //var result2 = pathfinder.Search(p1, p2); //Assert.AreEqual(MimanPathStatus.FOUND_GOAL, result2.status); }
public void WalkThroughSeveralRoomsUsingDoorsOnTheWay() { MimanPathfinder2.ClearRoomNetwork(); _adam.logger.AddListener(Console.WriteLine); _adam.position = new WorldCoordinate("Eden", 0, 4); _adam.WalkTo(new WorldCoordinate("Kitchen", 3, 3)); WorldTestHelper.UpdateWorld(_world, 20f); Assert.AreEqual(new WorldCoordinate("Kitchen", 3, 3), _adam.position); }