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()
self.map_mode = 'terrain only'
def switch_mode(self, mode_name):
+
+ def fail(msg, return_mode='play'):
+ self.log_msg('? ' + msg)
+ self.flash = True
+ self.switch_mode(return_mode)
+
if self.mode and self.mode.name == 'control_tile_draw':
self.log_msg('@ finished tile protection drawing.')
self.tile_draw = False
if mode_name == 'command_thing' and\
(not self.game.player.carrying or
not self.game.player.carrying.commandable):
- self.log_msg('? not carrying anything commandable')
- self.flash = True
- self.switch_mode('play')
- return
+ return fail('not carrying anything commandable')
+ if mode_name == 'take_thing' and self.game.player.carrying:
+ return fail('already carrying something')
if mode_name == 'drop_thing' and not self.game.player.carrying:
- self.log_msg('? not carrying anything droppable')
- self.flash = True
- self.switch_mode('play')
- return
+ return fail('not carrying anything droppable')
if mode_name == 'admin_enter' and self.is_admin:
mode_name = 'admin'
elif mode_name in {'name_thing', 'admin_thing_protect'}:
thing = t
break
if not thing:
- self.flash = True
- self.log_msg('? not standing over thing')
- return
+ return fail('not standing over thing', 'edit')
else:
self.thing_selected = thing
self.mode = getattr(self, 'mode_' + mode_name)
self.selectables = [t.id_ for t in self.game.things
if t.portable and t.position in select_range]
if len(self.selectables) == 0:
- self.log_msg('none')
- self.flash = True
- self.switch_mode('play')
- return
+ return fail('nothing to pick-up')
else:
for i in range(len(self.selectables)):
t = self.game.get_thing(self.selectables[i])
keycode = None
if len(key) == 1:
keycode = ord(key)
+ self.show_help = False
if key == 'KEY_RESIZE':
reset_screen_size()
elif self.mode.has_input_prompt and key == 'KEY_BACKSPACE':
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'):
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'):