def test_print_inventory(self): char = character.Pc() invent = char.inventory invent.append(items.ScimatarRune()) check_string = 'bone\nscimatar rune' self.assertEqual(snapshot_printer.print_inventory(char.inventory), check_string)
def test_inventory(self): an_arena = arena.Arena(12, 12) snap = world.WorldSnapshot(an_arena) test_loc = an_arena.get_location(spatial.Point(1, 1)) test_pc = character.Pc() test_loc.additem(test_pc) self.assertEquals(test_pc.inventory, queries.inventory(snap, test_pc.id))
def test_move(self): the_world = world.World() man = character.Pc() the_world.current.arena.get_location(spatial.Point(1, 5)).additem(man) self.assertEqual(the_world.current.arena.find_character(man), spatial.Point(1, 5)) world.move(the_world.current, man.id, 'E', lambda x: x) self.assertEqual(the_world.current.arena.find_character(man), spatial.Point(1, 6)) world.move(the_world.current, man.id, 'N', lambda x: x) self.assertEqual(the_world.current.arena.find_character(man), spatial.Point(0, 6))
def test_pickup(self): the_world = world.World() man = character.Pc() key = items.Bone() the_world.current.arena.get_location(spatial.Point(5, 5)).additem(man) the_world.current.arena.get_location(spatial.Point(5, 5)).items.append(key) world.pickup(the_world.current, man.id, lambda x: x) self.assertGreater(len(man.inventory), 0) kitty = bestiary.Cat() the_world.current.arena.get_location(spatial.Point(5, 7)).additem(kitty) kitty.kill() the_world.attempt(man.id, actions.Move('E')) the_world.attempt(man.id, actions.Move('E')) world.pickup(the_world.current, man.id, lambda x: x)
def test_death(self): the_world = world.World() the_world.genMobs = lambda x: [] man = character.Pc() world.spawn(the_world.current, man) location = the_world.current.arena.find_character_location(man) location.characters[0].kill() loc = the_world.current.arena.find_character(man) the_world.attempt(man.id, actions.Move('E')) new_man = the_world.current.arena.find(man.id) self.assertIsNone(new_man) self.assertEqual(0, len(the_world.current.pcs)) if the_world.current.arena.in_grid(loc.add(spatial.Point(0, 1))): self.assertGreater(len(the_world.current.arena.get_location(loc.add(spatial.Point(0, 1))).items), 0)
def __init__(self): self.world = world.World() hero = character.Pc() self.hero_id = hero.id self.world.spawn(hero) self.active = True