def update_fov_for(self, x, y): # libtcod.map_set_properties(self.current.fov_map, x, y, not self.tile_at(x, y).flags & features.BLOCK_LOS, # not self.tile_at(x, y).flags & features.BLOCK_WALK) # if self.tile_at(x, y).flags & features.BLOCK_LOS: # flags = rlfl.CELL_WALK xy = (x, y) fov_map_ = self.current.fov_map0 tile = self.tile_at(*xy) if not tile: return if tile.flags & features.BLOCK_WALK: if tile.flags & features.BLOCK_LOS == features.BLOCK_LOS: return flags = rlfl.get_flags(fov_map_, xy) flags |= rlfl.CELL_OPEN | rlfl.CELL_WALK rlfl.set_flag(fov_map_, xy, flags)
def test_flags(self): m = rlfl.create_map(20, 20) test = ( { 'p': (10, 10), 'm': -1, 's': 'Map not initialized', 'f': rlfl.CELL_OPEN }, { 'p': (-1, -1), 'm': m, 's': 'Location out of bounds', 'f': rlfl.CELL_OPEN }, { 'p': (1, 1), 'm': m, 's': 'Invalid flag used', 'f': -1 }, ) for func in ['has_flag', 'set_flag', 'clear_flag']: for i in test: try: getattr(rlfl, func)(i['m'], i['p'], i['f']) except Exception as e: self.assertEqual(str(e), i['s']) self.assertEqual(str(e.__class__), "<class 'rlfl.Error'>") else: self.fail('Expected Exception: func: %s, %s' % (func, i['s'])) for i in test[0:2]: try: f = rlfl.get_flags(i['m'], i['p']) self.assertEqual(f, 0) except Exception as e: self.assertEqual(str(e), i['s']) self.assertEqual(str(e.__class__), "<class 'rlfl.Error'>") else: self.fail('Expected Exception: func: %s, %s' % ('get_flags', i['s']))