X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;f=rogue_chat_curses.py;h=57c3750892c9049081ba255b8e77f42b5d46f4e6;hb=c4dda73a80b3149ba2b156e18c2598af6dbfdcb3;hp=ff559246fe1cbdf22aec2879a41ecf3b7ab3777a;hpb=6861e33d8edc80a8d1cf0244b6938620cc9a2991;p=plomrogue2 diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py index ff55924..57c3750 100755 --- a/rogue_chat_curses.py +++ b/rogue_chat_curses.py @@ -174,7 +174,6 @@ class PlomSocketClient(PlomSocket): pass # we assume socket will be known as dead by now def cmd_TURN(game, n): - game.turn = n game.turn_complete = False cmd_TURN.argtypes = 'int:nonneg' @@ -187,7 +186,9 @@ cmd_OTHER_WIPE.argtypes = '' def cmd_LOGIN_OK(game): game.tui.switch_mode('post_login_wait') game.tui.send('GET_GAMESTATE') - game.tui.log_msg('@ welcome') + game.tui.log_msg('@ welcome!') + game.tui.log_msg('@ hint: see top of terminal for how to get help.') + game.tui.log_msg('@ hint: enter study mode to understand your environment.') cmd_LOGIN_OK.argtypes = '' def cmd_ADMIN_OK(game): @@ -294,6 +295,8 @@ def cmd_GAME_STATE_COMPLETE(game): game.map_control_content = game.map_control_content_new 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.energy = game.energy_new game.turn_complete = True if game.tui.mode.name == 'post_login_wait': game.tui.switch_mode('play') @@ -361,6 +364,11 @@ def cmd_RANDOM_COLORS(game): game.tui.set_random_colors() cmd_RANDOM_COLORS.argtypes = '' +def cmd_STATS(game, bladder_pressure, energy): + game.bladder_pressure_new = bladder_pressure + game.energy_new = energy +cmd_STATS.argtypes = 'int:nonneg int' + class Game(GameBase): turn_complete = False tasks = {} @@ -400,6 +408,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_STATS) self.map_content = '' self.players_hat_chars = '' self.player_id = -1 @@ -503,7 +512,7 @@ class TUI: "command_thing", "take_thing", "drop_thing"] self.mode_play.available_actions = ["move", "teleport", "door", "consume", - "install", "wear", "spin"] + "install", "wear", "spin", "dance"] self.mode_study.available_modes = ["chat", "play", "admin_enter", "edit"] self.mode_study.available_actions = ["toggle_map_mode", "move_explorer"] self.mode_admin.available_modes = ["admin_thing_protect", "control_pw_type", @@ -557,6 +566,7 @@ class TUI: 'install': 'I', 'wear': 'W', 'spin': 'S', + 'dance': 'T', 'help': 'h', 'toggle_map_mode': 'L', 'toggle_tile_draw': 'm', @@ -693,7 +703,7 @@ class TUI: not self.game.player.carrying.commandable): return fail('not carrying anything commandable') if mode_name == 'name_thing' and not self.game.player.carrying: - return fail('not carrying anything to re-name') + return fail('not carrying anything to re-name', 'edit') if mode_name == 'admin_thing_protect' and not self.game.player.carrying: return fail('not carrying anything to protect') if mode_name == 'take_thing' and self.game.player.carrying: @@ -936,10 +946,10 @@ class TUI: safe_addstr(y, self.window_width, self.input_lines[i]) y += 1 - def draw_turn(): - if not self.game.turn_complete: - return - safe_addstr(0, self.window_width, 'TURN: ' + str(self.game.turn)) + def draw_stats(): + stats = 'ENERGY: %s BLADDER: %s' % (self.game.energy, + self.game.bladder_pressure) + safe_addstr(0, self.window_width, stats) def draw_mode(): help = "hit [%s] for help" % self.keys['help'] @@ -1087,7 +1097,7 @@ class TUI: draw_history() draw_mode() if not self.mode.is_intro: - draw_turn() + draw_stats() draw_map() if self.show_help: draw_help() @@ -1135,6 +1145,7 @@ class TUI: 'door': 'open/close', 'consume': 'consume', 'spin': 'spin', + 'dance': 'dance', } action_tasks = { @@ -1148,6 +1159,7 @@ class TUI: 'command': 'COMMAND', 'consume': 'INTOXICATE', 'spin': 'SPIN', + 'dance': 'DANCE', } curses.curs_set(False) # hide cursor @@ -1158,6 +1170,7 @@ class TUI: reset_screen_size() self.explorer = YX(0, 0) self.input_ = '' + store_widechar = False input_prompt = '> ' interval = datetime.timedelta(seconds=5) last_ping = datetime.datetime.now() - interval @@ -1192,6 +1205,13 @@ class TUI: keycode = None if len(key) == 1: keycode = ord(key) + # workaround for + if store_widechar: + store_widechar = False + key = bytes([195, keycode]).decode() + if keycode == 195: + store_widechar = True + continue self.show_help = False self.draw_face = False if key == 'KEY_RESIZE': @@ -1320,6 +1340,8 @@ class TUI: self.send('TASK:WEAR') elif key == self.keys['spin'] and task_action_on('spin'): self.send('TASK:SPIN') + elif key == self.keys['dance'] and task_action_on('dance'): + self.send('TASK:DANCE') elif key == self.keys['teleport']: if self.game.player.position in self.game.portals: self.host = self.game.portals[self.game.player.position]