X-Git-Url: https://plomlompom.com/repos/day?a=blobdiff_plain;f=plomrogue%2Fgame.py;h=1dc1e92cd2a29a0a28a72aa22a5d4365741fa95d;hb=679c7c1932187a3ca008dad2e580e0e1080482fc;hp=6e8afdf83182dded8a25c735b94dc7cdc2a7095a;hpb=54d8db95b3bb690b712ec09179922829d0c68a54;p=plomrogue2 diff --git a/plomrogue/game.py b/plomrogue/game.py index 6e8afdf..1dc1e92 100755 --- a/plomrogue/game.py +++ b/plomrogue/game.py @@ -210,6 +210,22 @@ class Game(GameBase): return '/O O\\' + '| oo |' + '\\>-- 0: + t_old = self.get_thing(id_) + t = self.thing_types[type_](self, id_=id_, position=position) + if t_old: + self.things[self.things.index(t_old)] = t + else: + self.things += [t] + self.changed_fovs = True + return t + def send_gamestate(self, connection_id=None): """Send out game state data relevant to clients.""" @@ -294,8 +310,7 @@ class Game(GameBase): t = self.get_player(connection_id) if hasattr(t, 'name'): self.io.send('CHAT ' + quote(t.name + ' left the map.')) - self.things.remove(t) - self.changed_fovs = True + self.remove_thing(t) to_delete += [connection_id] for connection_id in to_delete: del self.sessions[connection_id] @@ -313,7 +328,7 @@ class Game(GameBase): 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]: + for t in [t for t in self.things if t.type_ == 'Player']: t.invalidate_map_view() if self.changed: self.turn += 1