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':
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]
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] = '.'
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
- self.nickname = 'undefined'
+ self.nickname = 'undefined'
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: