X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bdeck_id%7D%7D/cards/%7B%7Bcard_id%7D%7D/form?a=blobdiff_plain;f=plomrogue%2Fgame.py;h=6e8afdf83182dded8a25c735b94dc7cdc2a7095a;hb=54d8db95b3bb690b712ec09179922829d0c68a54;hp=5e206b9c8c289155a59aa7700dd9306ea4e05e79;hpb=4d2cf315344ec4a376ffb3f49f02674e4b5facb6;p=plomrogue2 diff --git a/plomrogue/game.py b/plomrogue/game.py index 5e206b9..6e8afdf 100755 --- a/plomrogue/game.py +++ b/plomrogue/game.py @@ -117,6 +117,7 @@ class Game(GameBase): def __init__(self, save_file, *args, **kwargs): super().__init__(*args, **kwargs) self.changed = True + self.changed_fovs = True self.io = GameIO(self, save_file) self.tasks = {} self.thing_types = {} @@ -206,39 +207,45 @@ class Game(GameBase): if t.name in self.faces: return self.faces[t.name] else: - return 'O O' + ' v ' + '>-<' + return '/O O\\' + '| oo |' + '\\>-- 0: + print('DEBUG regenerating FOVs') + pool = multiprocessing.Pool() + new_fovs = pool.map(FovMap.init_terrain, [fov for fov in player_fovs]) #! + pool.close() + pool.join() + for i in range(len(player_fov_ids)): + id_ = player_fov_ids[i] + player = self.get_thing(id_) + player._fov = new_fovs[i] for c_id in c_ids: player = self.get_player(c_id) - visible_terrain = player.fov_stencil_map() self.io.send('FOV %s' % quote(player.fov_stencil.terrain), c_id) self.io.send('MAP %s %s %s' % (self.get_map_geometry_shape(), player.fov_stencil.geometry.size, - quote(visible_terrain)), c_id) - visible_control = player.fov_stencil_map('control') - self.io.send('MAP_CONTROL %s' % quote(visible_control), c_id) + quote(player.visible_terrain)), c_id) + self.io.send('MAP_CONTROL %s' % quote(player.visible_control), c_id) for t in [t for t in self.things if player.fov_test(*t.position)]: target_yx = player.fov_stencil.target_yx(*t.position) self.io.send('THING %s %s %s %s %s' % (target_yx, t.type_, @@ -288,6 +295,7 @@ class Game(GameBase): if hasattr(t, 'name'): self.io.send('CHAT ' + quote(t.name + ' left the map.')) self.things.remove(t) + self.changed_fovs = True to_delete += [connection_id] for connection_id in to_delete: del self.sessions[connection_id] @@ -304,6 +312,9 @@ class Game(GameBase): for connection_id in [c_id for c_id in self.sessions if self.sessions[c_id]['thing_id'] == t.id_]: self.io.send('PLAY_ERROR ' + quote(str(e)), connection_id) + if self.changed_fovs: + for t in [t for t in self.things]: + t.invalidate_map_view() if self.changed: self.turn += 1 # send_gamestate() can be rather expensive, due to among other reasons @@ -312,6 +323,7 @@ class Game(GameBase): datetime.datetime.now() -self.send_gamestate_interval: self.send_gamestate() self.changed = False + self.changed_fovs = False self.save() self.last_send_gamestate = datetime.datetime.now()