Beispiel #1
0
 def test_exits_and_doors(self):
     o = base.Exit("east", "target", "somewhere")
     o.enter_msg = "you enter a dark hallway"
     x = serializecycle(o)
     assert x["__class__"] == "tale.base.Exit"
     assert x["_target_str"] == "target"
     assert x["target"] is None
     assert x["descr"] == x["short_descr"] == "somewhere"
     assert x["enter_msg"] == "you enter a dark hallway"
     assert x["name"] == "east"
     assert x["title"] == "Exit to <unbound:target>"
     assert x["vnum"] > 0
     o = base.Door("east",
                   "target",
                   "somewhere",
                   locked=True,
                   opened=False,
                   key_code="123")
     o.enter_msg = "going through"
     assert o.description == "somewhere It is closed and locked."
     x = serializecycle(o)
     assert x["__class__"] == "tale.base.Door"
     assert x["_target_str"] == "target"
     assert x["target"] is None
     assert x["descr"] == "somewhere It is closed and locked."
     assert x["short_descr"] == "somewhere"
     assert x["enter_msg"] == "going through"
     assert x["key_code"] == "123"
     assert x["linked_door"] is None
     assert x["name"] == "east"
     assert x["title"] == "Exit to <unbound:target>"
     assert x["locked"] == True
     assert x["opened"] == False
     assert x["vnum"] > 0
Beispiel #2
0
 def test_location(self):
     room = base.Location("room", "description")
     thing = base.Item("thing")
     room.insert(thing, None)
     npc = base.Living("dog", "m")
     room.insert(npc, None)
     x = serializecycle(room)
     assert x["__class__"] == "tale.base.Location"
     assert x["name"] == "room"
     assert x["descr"] == "description"
     assert x["exits"] == ()
     assert len(x["items"]) == 1
     assert len(x["livings"]) == 1
     assert isinstance(x["items"], set)
     assert isinstance(x["livings"], set)
     x_item = x["items"].pop()
     x_living = x["livings"].pop()
     assert len(x_item) == 4
     assert x_item[0] > 0
     assert x_item[1] == "thing"
     assert len(x_living) == 4
     assert x_living[0] > 0
     assert x_living[1] == "dog"
     # now add some exits and a second location, and try again
     room2 = base.Location("room2", "description")
     exit1 = base.Exit("room2", room2, "to room2")
     exit2 = base.Exit("room", room, "back to room")
     room.add_exits([exit1])
     room2.add_exits([exit2])
     x1, x2 = serializecycle([room, room2])
     assert len(x1["exits"]) == 1
     assert isinstance(x1["exits"], set)
     assert len(x2["exits"]) == 1
     assert isinstance(x2["exits"], set)
     x_exit = x1["exits"].pop()
     assert len(x_exit) == 4
     assert x_exit[0] > 0
     assert x_exit[1] == "room2"
     assert x_exit[2] == x_exit[3] == "tale.base.Exit"
     assert x2["name"] == "room2"
     x_exit = x2["exits"].pop()
     assert len(x_exit) == 4
     assert x_exit[0] > 0
     assert x_exit[1] == "room"
Beispiel #3
0
 def test_exits_and_doors(self):
     o = base.Exit("east", "target", "somewhere")
     x = serializecycle(o)
     self.assertFalse(x.bound)
     self.assertEqual("target", x.target)
     self.assertEqual("somewhere", x.short_description)
     self.assertEqual("east", x.name)
     o = base.Door("east", "target", "somewhere", locked=True, opened=False)
     self.assertEqual("somewhere It is closed and locked.", o.description)
     x = serializecycle(o)
     self.assertEqual("target", x.target)
     self.assertEqual("east", x.name)
     self.assertEqual("somewhere It is closed and locked.", x.description)
Beispiel #4
0
 def test_location(self):
     room = base.Location("room", "description")
     x = serializecycle(room)
     self.assertEqual("room", x.name)
     self.assertEqual(set(), x.livings)
     self.assertEqual(set(), x.items)
     # now add some exits and a second location, and try again
     room2 = base.Location("room2", "description")
     exit1 = base.Exit("room2", room2, "to room2")
     exit2 = base.Exit("room", room, "back to room")
     room.add_exits([exit1])
     room2.add_exits([exit2])
     [r1, r2] = serializecycle([room, room2])
     self.assertEqual("room", r1.name)
     self.assertEqual("room2", r2.name)
     self.assertEqual(1, len(r1.exits))
     self.assertEqual(1, len(r2.exits))
     exit1 = r1.exits["room2"]
     exit2 = r2.exits["room"]
     self.assertEqual("to room2", exit1.short_description)
     self.assertEqual("back to room", exit2.short_description)
     self.assertEqual(r2, exit1.target)
     self.assertEqual(r1, exit2.target)