X-Git-Url: https://plomlompom.com/repos/berlin_corona.txt?a=blobdiff_plain;f=rogue_chat_curses.py;h=fdfc2bcbfb12096dd8b36148f48b2b63454242d8;hb=075ed2b9529e52ab8a5075d56d77e09d2191d9c7;hp=f75877aff1af88ca76cdf0e228c58cac01a69f1c;hpb=836f37cfc14cd1a27ac5aee1f8465925a7ed87c4;p=plomrogue2 diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py index f75877a..fdfc2bc 100755 --- a/rogue_chat_curses.py +++ b/rogue_chat_curses.py @@ -200,6 +200,11 @@ def cmd_CHAT(game, msg): game.tui.do_refresh = True cmd_CHAT.argtypes = 'string' +def cmd_CHATFACE(game, thing_id): + game.tui.draw_face = thing_id + game.tui.do_refresh = True +cmd_CHATFACE.argtypes = 'int:pos' + def cmd_PLAYER_ID(game, player_id): game.player_id = player_id cmd_PLAYER_ID.argtypes = 'int:nonneg' @@ -348,6 +353,7 @@ class Game(GameBase): self.register_command(cmd_ADMIN_OK) self.register_command(cmd_PONG) self.register_command(cmd_CHAT) + self.register_command(cmd_CHATFACE) self.register_command(cmd_REPLY) self.register_command(cmd_PLAYER_ID) self.register_command(cmd_TURN) @@ -475,10 +481,11 @@ class TUI: self.mode_control_tile_draw.available_modes = ["admin_enter"] self.mode_control_tile_draw.available_actions = ["move_explorer", "toggle_tile_draw"] - self.mode_edit.available_modes = ["write", "annotate", "portal", "name_thing", - "password", "chat", "study", "play", - "admin_enter", "enter_face"] - self.mode_edit.available_actions = ["move", "flatten", "toggle_map_mode"] + self.mode_edit.available_modes = ["write", "annotate", "portal", + "name_thing", "enter_face", "password", + "chat", "study", "play", "admin_enter"] + self.mode_edit.available_actions = ["move", "flatten", "install", + "toggle_map_mode"] self.mode = None self.host = host self.game = Game() @@ -629,13 +636,14 @@ class TUI: def switch_mode(self, mode_name): - def fail(msg): + def fail(msg, return_mode='play'): self.log_msg('? ' + msg) self.flash = True - self.switch_mode('play') + self.switch_mode(return_mode) if self.mode and self.mode.name == 'control_tile_draw': self.log_msg('@ finished tile protection drawing.') + self.draw_face = False self.tile_draw = False if mode_name == 'command_thing' and\ (not self.game.player.carrying or @@ -655,7 +663,7 @@ class TUI: thing = t break if not thing: - return fail('not standing over thing') + return fail('not standing over thing', 'edit') else: self.thing_selected = thing self.mode = getattr(self, 'mode_' + mode_name) @@ -956,6 +964,26 @@ class TUI: term_y += 1 map_y += 1 + def draw_face_popup(): + t = self.game.get_thing(self.draw_face) + if not t or not hasattr(t, 'face'): + self.draw_face = False + return + + start_x = self.window_width - 10 + def draw_body_part(body_part, end_y): + safe_addstr(end_y - 4, start_x, ' ________ ') + safe_addstr(end_y - 3, start_x, '| |') + safe_addstr(end_y - 2, start_x, '| ' + body_part[0:6] + ' |') + safe_addstr(end_y - 1, start_x, '| ' + body_part[6:12] + ' |') + safe_addstr(end_y, start_x, '| ' + body_part[12:18] + ' |') + + if hasattr(t, 'face'): + draw_body_part(t.face, self.size.y - 2) + if hasattr(t, 'hat'): + draw_body_part(t.hat, self.size.y - 5) + safe_addstr(self.size.y - 1, start_x, '| |') + def draw_help(): content = "%s help\n\n%s\n\n" % (self.mode.short_desc, self.mode.help_intro) @@ -1004,6 +1032,8 @@ class TUI: draw_map() if self.show_help: draw_help() + if self.draw_face and self.mode.name in {'chat', 'play'}: + draw_face_popup() def pick_selectable(task_name): try: @@ -1087,6 +1117,8 @@ class TUI: keycode = None if len(key) == 1: keycode = ord(key) + self.show_help = False + self.draw_face = False if key == 'KEY_RESIZE': reset_screen_size() elif self.mode.has_input_prompt and key == 'KEY_BACKSPACE': @@ -1214,8 +1246,6 @@ class TUI: self.send('TASK:DOOR') elif key == self.keys['consume'] and task_action_on('consume'): self.send('TASK:INTOXICATE') - elif key == self.keys['install'] and task_action_on('install'): - self.send('TASK:INSTALL') elif key == self.keys['wear'] and task_action_on('wear'): self.send('TASK:WEAR') elif key == self.keys['spin'] and task_action_on('spin'): @@ -1249,6 +1279,8 @@ class TUI: continue elif key == self.keys['flatten'] and task_action_on('flatten'): self.send('TASK:FLATTEN_SURROUNDINGS ' + quote(self.password)) + elif key == self.keys['install'] and task_action_on('install'): + self.send('TASK:INSTALL %s' % quote(self.password)) elif key == self.keys['toggle_map_mode']: self.toggle_map_mode() elif key in self.movement_keys and task_action_on('move'):