Add some more handling for commands

This commit is contained in:
Joe S 2021-02-23 23:53:27 -05:00
parent f0f7c40617
commit 5184bd9121
1 changed files with 15 additions and 3 deletions

View File

@ -22,10 +22,22 @@ class Handler(npyscreen.ButtonPress):
except IndexError:
self.parent.parentApp.log.warn('Command "{0}" could not be split, was it malformed or incomplete?'.format(raw_command))
command = ''
arguments = parsed_command # Whatever is left in the list, are arguments.
arguments = parsed_command # Whatever is left in the list, are arguments.
# Handle an empty command
if len(command) <= 2:
self.parent.update_log('Command was too short, try something like "MOVE", "PICK UP" or "USE".')
else:
# Concatenate everything back together (just to show the user the program understood them correctly
self.parent.update_log(command + ' ' + ' '.join(str(s) for s in arguments))
# Log the command that we parsed
self.parent.parentApp.log.info('Parsed command "{0}" with arguments "{1}"'.format(command, arguments))
self.parent.update_log('command: ' + command)
self.parent.update_log('args: {0}'.format(arguments))
# Make sure to re-draw the art box when we're all done (in case we updated it in logic above)
self.parent.artContent.display()
# Switch back to the game menu.
#TODO: possibly deprecate this statement?
self.parent.parentApp.switchForm('GAME')