X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=rogue_chat_curses.py;h=99a7e88bc94b0f0bccf81c0bd3228335226765fe;hb=d4419f2d3b883a20111d8258fb4f625094e9c587;hp=99400941f09e3ef9b30b4660b3e4e9b24f4953a5;hpb=4c164d8ac34965d2cc4e4e1f570c34789ec07fe1;p=plomrogue2 diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py index 9940094..99a7e88 100755 --- a/rogue_chat_curses.py +++ b/rogue_chat_curses.py @@ -51,6 +51,8 @@ class PlomSocketClient(PlomSocket): pass # we assume socket will be known as dead by now def cmd_TURN(game, n): + game.info_db = {} + game.info_hints = [] game.turn = n game.things = [] game.portals = {} @@ -124,7 +126,6 @@ def cmd_MAP_CONTROL(game, content): cmd_MAP_CONTROL.argtypes = 'string' def cmd_GAME_STATE_COMPLETE(game): - game.info_db = {} if game.tui.mode.name == 'post_login_wait': game.tui.switch_mode('play') if game.tui.mode.shows_info: @@ -138,7 +139,8 @@ def cmd_PORTAL(game, position, msg): cmd_PORTAL.argtypes = 'yx_tuple:nonneg string' def cmd_PLAY_ERROR(game, msg): - game.tui.flash() + game.tui.log_msg('? ' + msg) + game.tui.flash = True game.tui.do_refresh = True cmd_PLAY_ERROR.argtypes = 'string' @@ -152,8 +154,13 @@ def cmd_ARGUMENT_ERROR(game, msg): game.tui.do_refresh = True cmd_ARGUMENT_ERROR.argtypes = 'string' +def cmd_ANNOTATION_HINT(game, position): + game.info_hints += [position] +cmd_ANNOTATION_HINT.argtypes = 'yx_tuple:nonneg' + def cmd_ANNOTATION(game, position, msg): game.info_db[position] = msg + game.tui.restore_input_values() if game.tui.mode.shows_info: game.tui.do_refresh = True cmd_ANNOTATION.argtypes = 'yx_tuple:nonneg string' @@ -195,6 +202,7 @@ class Game(GameBase): self.register_command(cmd_MAP_CONTROL) self.register_command(cmd_PORTAL) self.register_command(cmd_ANNOTATION) + self.register_command(cmd_ANNOTATION_HINT) self.register_command(cmd_GAME_STATE_COMPLETE) self.register_command(cmd_ARGUMENT_ERROR) self.register_command(cmd_GAME_ERROR) @@ -204,6 +212,7 @@ class Game(GameBase): self.map_content = '' self.player_id = -1 self.info_db = {} + self.info_hints = [] self.portals = {} self.terrains = {} @@ -290,11 +299,9 @@ class TUI: self.force_instant_connect = True self.input_lines = [] self.fov = '' + self.flash = False curses.wrapper(self.loop) - def flash(self): - curses.flash() - def connect(self): def handle_recv(msg): @@ -367,6 +374,7 @@ class TUI: if self.mode.shows_info: player = self.game.get_thing(self.game.player_id) self.explorer = YX(player.position.y, player.position.x) + self.query_info() if self.mode.name == 'waiting_for_server': self.log_msg('@ waiting for server …') if self.mode.name == 'edit': @@ -425,12 +433,12 @@ class TUI: self.window_width) def move_explorer(direction): - target = self.game.map_geometry.move(self.explorer, direction) + target = self.game.map_geometry.move_yx(self.explorer, direction) if target: self.explorer = target self.query_info() else: - self.flash() + self.flash = True def draw_history(): lines = [] @@ -455,6 +463,10 @@ class TUI: if terrain_char in self.game.terrains: terrain_desc = self.game.terrains[terrain_char] info = 'TERRAIN: "%s" / %s\n' % (terrain_char, terrain_desc) + protection = self.game.map_control_content[pos_i] + if protection == '.': + protection = 'unprotected' + info = 'PROTECTION: %s\n' % protection for t in self.game.things: if t.position == self.explorer: info += 'THING: %s / %s' % (t.type_, @@ -508,7 +520,10 @@ class TUI: start = self.game.map_geometry.size.x * y end = start + self.game.map_geometry.size.x map_lines_split += [[c + ' ' for c in map_content[start:end]]] - if self.map_mode == 'terrain': + if self.map_mode == 'annotations': + for p in self.game.info_hints: + map_lines_split[p.y][p.x] = 'A ' + elif self.map_mode == 'terrain': for p in self.game.portals.keys(): map_lines_split[p.y][p.x] = 'P ' used_positions = [] @@ -576,13 +591,12 @@ class TUI: elif self.mode == self.mode_study: content += 'Available actions:\n' content += '[%s] – move question mark\n' % ','.join(self.movement_keys) - content += '[%s] – toggle view between terrain, and password protection areas\n' % self.keys['toggle_map_mode'] + content += '[%s] – toggle view between terrain, annotations, and password protection areas\n' % self.keys['toggle_map_mode'] content += '\n\nOther modes available from here:' content += '[%s] – chat mode\n' % self.keys['switch_to_chat'] content += '[%s] – play mode\n' % self.keys['switch_to_play'] elif self.mode == self.mode_chat: content += '/nick NAME – re-name yourself to NAME\n' - #content += '/msg USER TEXT – send TEXT to USER\n' content += '/%s or /play – switch to play mode\n' % self.keys['switch_to_play'] content += '/%s or /study – switch to study mode\n' % self.keys['switch_to_study'] for i in range(self.size.y): @@ -635,6 +649,9 @@ class TUI: else: self.send('PING') last_ping = now + if self.flash: + curses.flash() + self.flash = False if self.do_refresh: draw_screen() self.do_refresh = False @@ -715,6 +732,8 @@ class TUI: self.switch_mode('play') elif key == self.keys['toggle_map_mode']: if self.map_mode == 'terrain': + self.map_mode = 'annotations' + elif self.map_mode == 'annotations': self.map_mode = 'control' else: self.map_mode = 'terrain' @@ -747,7 +766,7 @@ class TUI: self.host = self.game.portals[player.position] self.reconnect() else: - self.flash() + self.flash = True self.log_msg('? not standing on portal') elif key in self.movement_keys and 'MOVE' in self.game.tasks: self.send('TASK:MOVE ' + self.movement_keys[key])