From: Christian Heller Date: Tue, 10 Nov 2020 02:44:40 +0000 (+0100) Subject: Also inhibit FLATTEN_SURROUNDINGS with terrain passwording. X-Git-Url: https://plomlompom.com/repos/ledger?a=commitdiff_plain;h=34856a61dd6b52c506aafa2dfd7de9d1ab07ced7;p=plomrogue2 Also inhibit FLATTEN_SURROUNDINGS with terrain passwording. --- diff --git a/plomrogue/game.py b/plomrogue/game.py index accf35d..a6bc2a3 100755 --- a/plomrogue/game.py +++ b/plomrogue/game.py @@ -73,6 +73,14 @@ class Game(GameBase): print("FILE INPUT LINE %5s: %s" % (i, line), end='') self.io.handle_input(line, god_mode=True) + def can_do_tile_with_pw(self, yx, pw): + tile_class = self.map_control[yx] + if tile_class in self.map_control_passwords: + tile_pw = self.map_control_passwords[tile_class] + if pw != tile_pw: + return False + return True + def get_string_options(self, string_option_type): import string if string_option_type == 'direction': diff --git a/plomrogue/tasks.py b/plomrogue/tasks.py index 55669ec..2c0c3fc 100644 --- a/plomrogue/tasks.py +++ b/plomrogue/tasks.py @@ -51,11 +51,9 @@ class Task_WRITE(Task): argtypes = 'string:char string' def check(self): - tile_class = self.thing.game.map_control[self.thing.position] - if tile_class in self.thing.game.map_control_passwords: - tile_pw = self.thing.game.map_control_passwords[tile_class] - if self.args[1] != tile_pw: - raise GameError('wrong password for tile') + if not self.thing.game.can_do_tile_with_pw(self.thing.position, + self.args[1]): + raise GameError('wrong password for tile') def do(self): self.thing.game.map[self.thing.position] = self.args[0] @@ -64,12 +62,15 @@ class Task_WRITE(Task): class Task_FLATTEN_SURROUNDINGS(Task): todo = 10 + argtypes = 'string' def check(self): pass def do(self): - self.thing.game.map[self.thing.position] = '.' - for yx in self.thing.game.map_geometry.get_neighbors(self.thing.position).values(): + for yx in[self.thing.position] + \ + list(self.thing.game.map_geometry.get_neighbors(self.thing.position).values()): if yx is not None: + if not self.thing.game.can_do_tile_with_pw(yx, self.args[0]): + continue self.thing.game.map[yx] = '.' diff --git a/plomrogue/things.py b/plomrogue/things.py index 0e4af34..f066ae6 100644 --- a/plomrogue/things.py +++ b/plomrogue/things.py @@ -74,5 +74,5 @@ class ThingPlayer(ThingAnimate): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.nickname = 'undefined' + self.nickname = 'undefined' diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py index bf5ad1f..7ce1496 100755 --- a/rogue_chat_curses.py +++ b/rogue_chat_curses.py @@ -649,7 +649,7 @@ class TUI: self.switch_mode('edit') elif key == self.keys['flatten'] and\ 'FLATTEN_SURROUNDINGS' in self.game.tasks: - self.send('TASK:FLATTEN_SURROUNDINGS') + self.send('TASK:FLATTEN_SURROUNDINGS ' + quote(self.password)) 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: