From: Christian Heller Date: Wed, 16 Dec 2020 20:23:39 +0000 (+0100) Subject: Replace client TURN line with frequently updated toilet need stat. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/%7B%7Bdb.prefix%7D%7D/static/%7B%7Bprefix%7D%7D/templates?a=commitdiff_plain;h=15ad903f7da0dd35945f79ff26e4528378eaf31f;p=plomrogue2 Replace client TURN line with frequently updated toilet need stat. --- diff --git a/plomrogue/game.py b/plomrogue/game.py index d3ab1e7..5f91a11 100755 --- a/plomrogue/game.py +++ b/plomrogue/game.py @@ -136,9 +136,10 @@ class Game(GameBase): self.players_hat_chars = {} self.player_char_i = -1 self.admin_passwords = [] - self.send_gamestate_interval = datetime.timedelta(seconds=0.04) + self.send_gamestate_min_interval = datetime.timedelta(seconds=0.04) + self.send_gamestate_max_interval = datetime.timedelta(seconds=5) self.last_send_gamestate = datetime.datetime.now() -\ - self.send_gamestate_interval + self.send_gamestate_min_interval self.terrains = { '.': Terrain('.', 'floor'), 'X': Terrain('X', 'wall', blocks_light=True, blocks_sound=True, @@ -276,6 +277,7 @@ class Game(GameBase): player = self.get_player(c_id) self.io.send('PLAYERS_HAT_CHARS ' + quote(player.get_cookie_chars()), c_id) + self.io.send('BLADDER_PRESSURE %s' % player.need_for_toilet) if player.id_ in player_ids_send_fov: self.io.send('FOV %s' % quote(player.fov_stencil.terrain), c_id) self.io.send('MAP %s %s %s' % (self.get_map_geometry_shape(), @@ -387,12 +389,13 @@ class Game(GameBase): self.io.send('PLAY_ERROR ' + quote(str(e)), connection_id) # send gamestate if it makes sense at this point - if self.changed: + if self.changed or self.last_send_gamestate < \ + datetime.datetime.now() - self.send_gamestate_max_interval: self.turn += 1 # send_gamestate() can be rather expensive, due to among other reasons # re-calculating players' FOVs, so don't send it out too often if self.last_send_gamestate < \ - datetime.datetime.now() -self.send_gamestate_interval: + datetime.datetime.now() - self.send_gamestate_min_interval: n_changes = 0 for type_ in self.changed_tiles: n_changes += len(self.changed_tiles[type_]) diff --git a/rogue_chat.html b/rogue_chat.html index 212a1d6..291a98c 100644 --- a/rogue_chat.html +++ b/rogue_chat.html @@ -129,8 +129,8 @@ terminal rows: