X-Git-Url: https://plomlompom.com/repos/berlin_corona.txt?a=blobdiff_plain;f=rogue_chat_curses.py;h=fdfc2bcbfb12096dd8b36148f48b2b63454242d8;hb=075ed2b9529e52ab8a5075d56d77e09d2191d9c7;hp=8eb70d65e7ced5f998e2f681c550e4e3ca07df41;hpb=87b8e08add4c032f4f0aa7f07f4964719bbc4236;p=plomrogue2 diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py index 8eb70d6..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() @@ -636,6 +643,7 @@ class TUI: 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 @@ -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: @@ -1088,6 +1118,7 @@ class TUI: 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': @@ -1215,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'): @@ -1250,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'):