X-Git-Url: https://plomlompom.com/repos/todo?a=blobdiff_plain;f=rogue_chat_curses.py;h=64eaf03959436cc768af00c0b323a7ab66f41259;hb=8c5624db0c2b463a490a425fc0f8baf2761d7d23;hp=a6d1ca7a81e9f8632bd82d2bb9e482da8529aae8;hpb=540aec0e9bf55d0452cffda4b34e1995d3724abf;p=plomrogue2 diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py index a6d1ca7..64eaf03 100755 --- a/rogue_chat_curses.py +++ b/rogue_chat_curses.py @@ -143,6 +143,10 @@ def cmd_ANNOTATION(game, position, msg): game.tui.do_refresh = True cmd_ANNOTATION.argtypes = 'yx_tuple:nonneg string' +def cmd_TASKS(game, tasks_comma_separated): + game.tasks = tasks_comma_separated.split(',') +cmd_TASKS.argtypes = 'string' + def cmd_PONG(game): pass cmd_PONG.argtypes = '' @@ -150,6 +154,7 @@ cmd_PONG.argtypes = '' class Game(GameBase): thing_type = ThingBase turn_complete = False + tasks = {} def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -167,6 +172,7 @@ class Game(GameBase): self.register_command(cmd_ARGUMENT_ERROR) self.register_command(cmd_GAME_ERROR) self.register_command(cmd_PLAY_ERROR) + self.register_command(cmd_TASKS) self.map_content = '' self.player_id = -1 self.info_db = {} @@ -293,13 +299,18 @@ class TUI: self.log_msg(" /%s or /play - switch to play mode" % self.keys['switch_to_play']); self.log_msg(" /%s or /study - switch to study mode" % self.keys['switch_to_study']); self.log_msg("commands common to study and play mode:"); - self.log_msg(" %s - move" % ','.join(self.movement_keys)); + if 'MOVE' in self.game.tasks: + self.log_msg(" %s - move" % ','.join(self.movement_keys)); self.log_msg(" %s - switch to chat mode" % self.keys['switch_to_chat']); self.log_msg("commands specific to play mode:"); - self.log_msg(" %s - write following ASCII character" % self.keys['switch_to_edit']); - self.log_msg(" %s - flatten surroundings" % self.keys['flatten']); + if 'WRITE' in self.game.tasks: + self.log_msg(" %s - write following ASCII character" % self.keys['switch_to_edit']); + if 'FLATTEN_SURROUNDINGS' in self.game.tasks: + self.log_msg(" %s - flatten surroundings" % self.keys['flatten']); self.log_msg(" %s - switch to study mode" % self.keys['switch_to_study']); self.log_msg("commands specific to study mode:"); + if 'MOVE' not in self.game.tasks: + self.log_msg(" %s - move" % ','.join(self.movement_keys)); self.log_msg(" %s - annotate terrain" % self.keys['switch_to_annotate']); self.log_msg(" %s - switch to play mode" % self.keys['switch_to_play']); @@ -334,6 +345,7 @@ class TUI: self.socket = socket_client_class(handle_recv, self.host) self.socket_thread = threading.Thread(target=self.socket.run) self.socket_thread.start() + self.socket.send('TASKS') self.switch_mode('login') return except ConnectionRefusedError: @@ -549,7 +561,7 @@ class TUI: elif self.input_.startswith('/nick'): tokens = self.input_.split(maxsplit=1) if len(tokens) == 2: - self.send('LOGIN ' + quote(tokens[1])) + self.send('NICK ' + quote(tokens[1])) else: self.log_msg('? need login name') elif self.input_.startswith('/msg'): @@ -600,11 +612,13 @@ class TUI: self.switch_mode('chat') elif key == self.keys['switch_to_study']: self.switch_mode('study') - if key == self.keys['switch_to_edit']: + if key == self.keys['switch_to_edit'] and\ + 'WRITE' in self.game.tasks: self.switch_mode('edit') - elif key == self.keys['flatten']: + elif key == self.keys['flatten'] and\ + 'FLATTEN_SURROUNDINGS' in self.game.tasks: self.send('TASK:FLATTEN_SURROUNDINGS') - elif key in self.movement_keys: + elif key in self.movement_keys and 'MOVE' in self.game.tasks: self.send('TASK:MOVE ' + self.movement_keys[key]) elif self.mode == self.mode_edit: self.send('TASK:WRITE ' + key)