From 94f399dbee74479669095c3f79548ebae4a4cd80 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Fri, 27 Nov 2020 01:29:08 +0100 Subject: [PATCH] Enable player movement in admin mode. --- rogue_chat.html | 11 ++++++++++- rogue_chat_curses.py | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/rogue_chat.html b/rogue_chat.html index 15b715a..ffed950 100644 --- a/rogue_chat.html +++ b/rogue_chat.html @@ -672,7 +672,7 @@ let tui = { el.disabled = true; } document.getElementById("help").disabled = false; - if (this.mode.name == 'play' || this.mode.name == 'study' || this.mode.name == 'control_tile_draw' || this.mode.name == 'edit') { + if (this.mode.name == 'play' || this.mode.name == 'study' || this.mode.name == 'control_tile_draw' || this.mode.name == 'edit' || this.mode.name == 'admin') { for (const move_key of document.querySelectorAll('[id^="move_"]')) { move_key.disabled = false; } @@ -1033,6 +1033,12 @@ let tui = { content += '/' + this.keys.switch_to_study + ' or /study – switch to study mode\n'; content += '/' + this.keys.switch_to_edit + ' or /edit – switch to map edit mode\n'; content += '/' + this.keys.switch_to_admin_enter + ' or /admin – switch to admin mode\n'; + } else if (this.mode.name == 'admin') { + content += "Available actions:\n"; + if (game.tasks.includes('MOVE')) { + content += "[" + movement_keys_desc + "] – move player\n"; + } + content += '\n'; } content += this.mode.list_available_modes(); let start_x = 0; @@ -1411,6 +1417,9 @@ tui.inputEl.addEventListener('keydown', (event) => { } else if (tui.mode.name == 'admin') { if (tui.mode.mode_switch_on_key(event)) { null; + } else if (event.key in tui.movement_keys + && game.tasks.includes('MOVE')) { + server.send(['TASK:MOVE', tui.movement_keys[event.key]]); }; } else if (tui.mode.name == 'edit') { if (tui.mode.mode_switch_on_key(event)) { diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py index 5ad366a..86c6ba4 100755 --- a/rogue_chat_curses.py +++ b/rogue_chat_curses.py @@ -820,6 +820,11 @@ class TUI: content += '/%s or /study – switch to study mode\n' % self.keys['switch_to_study'] content += '/%s or /edit – switch to map edit mode\n' % self.keys['switch_to_edit'] content += '/%s or /admin – switch to admin mode\n' % self.keys['switch_to_admin_enter'] + elif self.mode.name == 'admin': + content += "Available actions:\n" + if 'MOVE' in self.game.tasks: + content += "[%s] – move player\n" % ','.join(self.movement_keys) + content += '\n' content += self.mode.list_available_modes(self) for i in range(self.size.y): safe_addstr(i, @@ -1024,6 +1029,8 @@ class TUI: elif self.mode.name == 'admin': if self.mode.mode_switch_on_key(self, key): continue + elif key in self.movement_keys and 'MOVE' in self.game.tasks: + self.send('TASK:MOVE ' + self.movement_keys[key]) elif self.mode.name == 'edit': if self.mode.mode_switch_on_key(self, key): continue -- 2.30.2