From 9fc4ed130c05c3625d506beca1b640bb15e7aa0d Mon Sep 17 00:00:00 2001 From: Joe S <31870999+KenwoodFox@users.noreply.github.com> Date: Mon, 22 Feb 2021 23:30:38 -0500 Subject: [PATCH] Add error handling to handler --- Adventure Game/adventure_game/Handler.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Adventure Game/adventure_game/Handler.py b/Adventure Game/adventure_game/Handler.py index c12c38a..fb4cc49 100644 --- a/Adventure Game/adventure_game/Handler.py +++ b/Adventure Game/adventure_game/Handler.py @@ -9,7 +9,20 @@ class Handler(npyscreen.ButtonPress): 3: re-render the screen """ def whenPressed(self): - self.parent.update_log(self.parent.dialogueBox.value) + # This is the raw command from the user + raw_command = self.parent.dialogueBox.value + + # This is the raw command from the user + parsed_command = raw_command.split() + + try: + command = parsed_command.pop(0) + except IndexError: + pass + arguments = parsed_command + + self.parent.update_log('command: ' + command) + self.parent.update_log('args: {0}'.format(arguments)) self.parent.dialogueBox.value = '' self.parent.artContent.display() self.parent.parentApp.switchForm('GAME')