def serializecycle(obj): ser = TaleSerializer() deser = TaleDeserializer() p = player.Player("julie", "f") data = ser.serialize(None, p, [obj], [], [], [], [], None) stuff = deser.deserialize(data) items = stuff["items"] assert len(items) == 1 return items[0]
def test_player_and_soul(self): o = soul.Soul() x = serializecycle(o) self.assertIsNotNone(x) p = player.Player("name", "n", description="description") p.title = "title" p.money = 42 x = serializecycle(p) self.assert_base_attrs(x) self.assertEqual(42, x.money)
def test_living_player(self): thing = base.Item("thing") p = player.Player("playername", "n", descr="description") p.insert(thing, None) p.title = "title" p.money = 42 p.brief = True p.story_data = {"data": 42} p.privileges.add("wizard") o = base.Living("name", "f", title="title", descr="description", race="dragon") o.aggressive = True o.following = p o.is_pet = True o.stats.attack_dice = "2d8" o.stats.level = 12 o.stats.hp = 100 x = serializecycle(o) assert x["__class__"] == "tale.base.Living" assert x["aggressive"] == True assert len(x["following"]) == 4 assert x["following"][1] == "playername" assert x["is_pet"] == True assert x["location"][1] == "Limbo" assert x["race"] == "dragon" assert len(x["privileges"]) == 0 assert "soul" not in x assert "teleported_from" not in x s = x["stats"] assert s["gender"] == "f" assert s["race"] == "dragon" assert s["attack_dice"] == "2d8" assert s["level"] == 12 assert s["hp"] == 100 x = serializecycle(p) assert x["__class__"] == x["__base_class__"] == "tale.player.Player" assert x["brief"] == True assert x["location"][1] == "Limbo" assert x["money"] == 42 assert x["name"] == "playername" assert x["story_data"]["data"] == 42 assert x["turns"] == 0 assert x["screen_width"] == p.screen_width assert x["hints"]["__class__"] == "tale.hints.HintSystem" assert x["hints"]["checkpoints"] == [None] assert x["stats"]["race"] == x["race"] == "human" assert x["stats"]["xp"] == 0 assert len(x["inventory"]) == 1 inv = x["inventory"].pop() assert inv[1] == "thing"
def setUp(self): mud_context.driver = FakeDriver() mud_context.config = StoryConfig() mud_context.resources = mud_context.driver.resources self.actor = player.Player("julie", "f")
def setUp(self): mud_context.driver = TestDriver() mud_context.config = Storybase()._get_config() self.actor = player.Player("julie", "f")