From: Christian Heller <c.heller@plomlompom.de> Date: Wed, 16 Dec 2020 20:57:04 +0000 (+0100) Subject: Add weariness mechanic. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/static/do_todos?a=commitdiff_plain;h=dfb05774efac717d1adc699e97b6140599e5df1e;p=plomrogue2 Add weariness mechanic. --- diff --git a/plomrogue/game.py b/plomrogue/game.py index 1658808..5e6c144 100755 --- a/plomrogue/game.py +++ b/plomrogue/game.py @@ -277,7 +277,8 @@ 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, c_id) + self.io.send('STATS %s %s' % (player.need_for_toilet, + player.weariness), c_id) 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(), diff --git a/plomrogue/things.py b/plomrogue/things.py index 3686ab0..c8ef346 100644 --- a/plomrogue/things.py +++ b/plomrogue/things.py @@ -452,6 +452,7 @@ class Thing_CookieSpawner(Thing): class ThingAnimate(Thing): + weariness = 0 def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -480,6 +481,7 @@ class ThingAnimate(Thing): task = self.next_task[0] self.next_task = [None] task.check() + task.todo += self.weariness * 10 return task def proceed(self): @@ -624,6 +626,11 @@ class Thing_Player(ThingAnimate): elif self.tripping > 0 and self.tripping % 250 == 0: self.send_msg('RANDOM_COLORS') self.game.changed = True + if random.random() > 0.9999: + if self.standing: + self.weariness += 1 + elif self.weariness > 0: + self.weariness -= 1 def send_msg(self, msg): for c_id in self.game.sessions: diff --git a/rogue_chat.html b/rogue_chat.html index 291a98c..84d481c 100644 --- a/rogue_chat.html +++ b/rogue_chat.html @@ -129,8 +129,8 @@ terminal rows: <input id="n_rows" type="number" step=4 min=24 value=24 /> </div> <script> "use strict"; -//let websocket_location = "wss://plomlompom.com/rogue_chat/"; -let websocket_location = "ws://localhost:8000/"; +let websocket_location = "wss://plomlompom.com/rogue_chat/"; +//let websocket_location = "ws://localhost:8000/"; let mode_helps = { 'play': { @@ -489,8 +489,9 @@ let server = { game.portals_new = {}; explorer.annotations_new = {}; game.things_new = []; - } else if (tokens[0] === 'BLADDER_PRESSURE') { + } else if (tokens[0] === 'STATS') { game.bladder_pressure_new = parseInt(tokens[1]) + game.weariness_new = parseInt(tokens[2]) } else if (tokens[0] === 'THING') { let t = game.get_thing_temp(tokens[4], true); t.position = parser.parse_yx(tokens[1]); @@ -548,6 +549,7 @@ let server = { game.player = game.things[game.player_id]; game.players_hat_chars = game.players_hat_chars_new; game.bladder_pressure = game.bladder_pressure_new + game.weariness = game.weariness_new game.turn_complete = true; if (tui.mode.name == 'post_login_wait') { tui.switch_mode('play'); @@ -1213,7 +1215,9 @@ let tui = { terminal.write(0, this.window_width, 'MODE: ' + this.mode.short_desc + ' â ' + help); }, draw_stats_line: function(n) { - terminal.write(1, this.window_width, 'BLADDER: ' + game.bladder_pressure); + terminal.write(1, this.window_width, + 'WEARINESS: ' + game.weariness + + ' BLADDER: ' + game.bladder_pressure); }, draw_history: function() { let log_display_lines = []; diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py index d469340..ec9eee5 100755 --- a/rogue_chat_curses.py +++ b/rogue_chat_curses.py @@ -294,6 +294,7 @@ def cmd_GAME_STATE_COMPLETE(game): game.player = game.get_thing(game.player_id) game.players_hat_chars = game.players_hat_chars_new game.bladder_pressure = game.bladder_pressure_new + game.weariness = game.weariness_new game.turn_complete = True if game.tui.mode.name == 'post_login_wait': game.tui.switch_mode('play') @@ -361,9 +362,10 @@ def cmd_RANDOM_COLORS(game): game.tui.set_random_colors() cmd_RANDOM_COLORS.argtypes = '' -def cmd_BLADDER_PRESSURE(game, bladder_pressure): +def cmd_STATS(game, bladder_pressure, weariness): game.bladder_pressure_new = bladder_pressure -cmd_BLADDER_PRESSURE.argtypes = 'int:nonneg' + game.weariness_new = weariness +cmd_STATS.argtypes = 'int:nonneg int:nonneg' class Game(GameBase): turn_complete = False @@ -404,7 +406,7 @@ class Game(GameBase): self.register_command(cmd_FOV) self.register_command(cmd_DEFAULT_COLORS) self.register_command(cmd_RANDOM_COLORS) - self.register_command(cmd_BLADDER_PRESSURE) + self.register_command(cmd_STATS) self.map_content = '' self.players_hat_chars = '' self.player_id = -1 @@ -414,8 +416,6 @@ class Game(GameBase): self.portals_new = {} self.terrains = {} self.player = None - self.bladder_pressure_new = 0 - self.bladder_pressure = 0 def get_string_options(self, string_option_type): if string_option_type == 'map_geometry': @@ -944,7 +944,9 @@ class TUI: y += 1 def draw_stats(): - safe_addstr(0, self.window_width, 'BLADDER: ' + str(self.game.bladder_pressure)) + stats = 'WEARY: %s BLADDER: %s' % (self.game.weariness, + self.game.bladder_pressure) + safe_addstr(0, self.window_width, stats) def draw_mode(): help = "hit [%s] for help" % self.keys['help']