def test_entering_portal_removes_character_from_old_level(self): """ Test that entering portal will remove character from level """ assert self.character.level == self.level1 assert self.character in get_characters(self.level1) pyherc.vtable['\ufdd0:move'](character=self.character, direction=Direction.enter) assert self.character not in get_characters(self.level1)
def test_entering_portal_adds_character_to_creatures(self): """ Test that entering portal will add character to the creatures list """ assert self.character.level == self.level1 assert self.character in get_characters(self.level1) pyherc.vtable['\ufdd0:move'](character=self.character, direction=Direction.enter) assert self.character.level == self.level2 assert self.character in get_characters(self.level2)
def _matches(self, item): """ Check if matcher matches item :param item: object to match against :returns: True if matching, otherwise False :rtype: Boolean """ self.item = item if item in get_characters(self.level): return True else: return False
def _matches(self, item): """ Check if matcher matches item :param item: object to match against :returns: True if matching, otherwise False :rtype: Boolean """ count = 0 for creature in get_characters(item): if creature.name == self.creature: count = count + 1 return self.amount.matches(count)
def __construct_scene(self, model, scene): """ Constructs scene to display """ for anim in [x for x in self.animations]: anim.stop() anim.clear() for adapter in self.animation_adapters: adapter.glyphs.clear() self.animations = [] scene.clear() self.current_level = model.player.level for location, tile in get_tiles(self.current_level): if tile['\ufdd0:floor']: new_glyph = MapGlyph(self.surface_manager.get_icon(tile['\ufdd0:floor']), None, self.animation_adapters[0]) new_glyph.setZValue(zorder_floor) new_glyph.setPos(location[0] * 32, location[1] * 32) scene.addItem(new_glyph) if tile['\ufdd0:wall']: new_glyph = MapGlyph(self.surface_manager.get_icon(tile['\ufdd0:wall']), None) new_glyph.setZValue(zorder_wall) new_glyph.setPos(location[0] * 32, location[1] * 32) scene.addItem(new_glyph) for tile_id in tile['\ufdd0:ornamentation']: new_glyph = MapGlyph(self.surface_manager.get_icon(tile_id), None, self.rng.choice(self.animation_adapters)) new_glyph.setZValue(zorder_ornament) new_glyph.setPos(location[0] * 32, location[1] * 32) scene.addItem(new_glyph) for item in tile['\ufdd0:items']: self.add_glyph(item, scene, zorder_item) for trap in tile['\ufdd0:traps']: self.add_glyph(trap, scene, zorder_trap) for creature in get_characters(self.current_level): self.add_glyph(creature, scene, zorder_character)
def __construct_scene(self, model, scene): """ Constructs scene to display """ for anim in [x for x in self.animations]: anim.stop() anim.clear() for adapter in self.animation_adapters: adapter.glyphs.clear() self.animations = [] scene.clear() self.current_level = model.player.level for location, tile in get_tiles(self.current_level): if tile['\ufdd0:floor']: new_glyph = MapGlyph( self.surface_manager.get_icon(tile['\ufdd0:floor']), None, self.animation_adapters[0]) new_glyph.setZValue(zorder_floor) new_glyph.setPos(location[0] * 32, location[1] * 32) scene.addItem(new_glyph) if tile['\ufdd0:wall']: new_glyph = MapGlyph( self.surface_manager.get_icon(tile['\ufdd0:wall']), None) new_glyph.setZValue(zorder_wall) new_glyph.setPos(location[0] * 32, location[1] * 32) scene.addItem(new_glyph) for tile_id in tile['\ufdd0:ornamentation']: new_glyph = MapGlyph(self.surface_manager.get_icon(tile_id), None, self.rng.choice(self.animation_adapters)) new_glyph.setZValue(zorder_ornament) new_glyph.setPos(location[0] * 32, location[1] * 32) scene.addItem(new_glyph) for item in tile['\ufdd0:items']: self.add_glyph(item, scene, zorder_item) for trap in tile['\ufdd0:traps']: self.add_glyph(trap, scene, zorder_trap) for creature in get_characters(self.current_level): self.add_glyph(creature, scene, zorder_character)
def describe_mismatch(self, item, mismatch_description): """ Describe this mismatch """ mismatch_description.append('Was level with creatures {0}' .format(get_characters(self.level)))