From: Christian Heller Date: Fri, 11 Dec 2020 00:41:04 +0000 (+0100) Subject: Password-protect tiles from (un-)installing things on them. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bprefix%7D%7D/all?a=commitdiff_plain;h=dc2747c7daca975526206bfadecc1dd0ddcc8d67;p=plomrogue2 Password-protect tiles from (un-)installing things on them. --- diff --git a/plomrogue/tasks.py b/plomrogue/tasks.py index 841a0e6..3dc0928 100644 --- a/plomrogue/tasks.py +++ b/plomrogue/tasks.py @@ -198,6 +198,7 @@ class Task_COMMAND(Task): class Task_INSTALL(Task): + argtypes = 'string' def _get_uninstallables(self): return [t for t in self.thing.game.things @@ -207,6 +208,9 @@ class Task_INSTALL(Task): and t.position == self.thing.position] def check(self): + if not self.thing.game.can_do_tile_with_pw(*self.thing.position, + self.args[0]): + raise GameError('wrong password for tile') if self.thing.carrying: if not hasattr(self.thing.carrying, 'installable')\ or not self.thing.carrying.installable: diff --git a/rogue_chat.html b/rogue_chat.html index 51e8078..3a63619 100644 --- a/rogue_chat.html +++ b/rogue_chat.html @@ -57,7 +57,6 @@ keyboard input/control: - @@ -67,6 +66,7 @@ keyboard input/control: + @@ -705,7 +705,7 @@ let tui = { this.mode_play.available_modes = ["chat", "study", "edit", "admin_enter", "command_thing", "take_thing", "drop_thing"] this.mode_play.available_actions = ["move", "teleport", "door", "consume", - "install", "wear", "spin"]; + "wear", "spin"]; this.mode_study.available_modes = ["chat", "play", "admin_enter", "edit"] this.mode_study.available_actions = ["toggle_map_mode", "move_explorer"]; this.mode_admin.available_modes = ["admin_thing_protect", "control_pw_type", @@ -717,7 +717,8 @@ let tui = { this.mode_edit.available_modes = ["write", "annotate", "portal", "name_thing", "password", "chat", "study", "play", "admin_enter", "enter_face"] - this.mode_edit.available_actions = ["move", "flatten", "toggle_map_mode"] + this.mode_edit.available_actions = ["move", "flatten", "install", + "toggle_map_mode"] this.inputEl = document.getElementById("input"); this.inputEl.focus(); this.switch_mode('waiting_for_server'); @@ -1589,8 +1590,6 @@ tui.inputEl.addEventListener('keydown', (event) => { server.send(["TASK:INTOXICATE"]); } else if (event.key === tui.keys.door && tui.task_action_on('door')) { server.send(["TASK:DOOR"]); - } else if (event.key === tui.keys.install && tui.task_action_on('install')) { - server.send(["TASK:INSTALL"]); } else if (event.key === tui.keys.wear && tui.task_action_on('wear')) { server.send(["TASK:WEAR"]); } else if (event.key === tui.keys.spin && tui.task_action_on('spin')) { @@ -1629,6 +1628,8 @@ tui.inputEl.addEventListener('keydown', (event) => { server.send(['TASK:MOVE', tui.movement_keys[event.key]]); } else if (event.key === tui.keys.flatten && tui.task_action_on('flatten')) { server.send(["TASK:FLATTEN_SURROUNDINGS", tui.password]); + } else if (event.key === tui.keys.install && tui.task_action_on('install')) { + server.send(["TASK:INSTALL", tui.password]); } else if (event.key == tui.keys.toggle_map_mode) { tui.toggle_map_mode(); } diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py index 8eb70d6..5046de1 100755 --- a/rogue_chat_curses.py +++ b/rogue_chat_curses.py @@ -475,10 +475,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() @@ -1215,8 +1216,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 +1249,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'):