diff --git a/Adventure Game/adventure_game/Handler.py b/Adventure Game/adventure_game/Handler.py index 1afe77d..42b9e02 100644 --- a/Adventure Game/adventure_game/Handler.py +++ b/Adventure Game/adventure_game/Handler.py @@ -10,6 +10,7 @@ class Handler(npyscreen.ButtonPress): 2: prepare new items to display on the screen 3: re-render the screen """ + def whenPressed(self): self.parent.parentApp.log.debug('Send button pressed!') # This is the raw command from the user @@ -24,7 +25,8 @@ class Handler(npyscreen.ButtonPress): try: command = parsed_command.pop(0) except IndexError: - self.parent.parentApp.log.warn('Command "{0}" could not be split, was it malformed or incomplete?'.format(raw_command)) + 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. @@ -44,17 +46,31 @@ class Handler(npyscreen.ButtonPress): player = self.parent.parentApp.player roomlocation = player.playerData['player']['location'] + '.yaml' try: - room = parse(self.parent.parentApp.mainPath / 'gamedata/world' / roomlocation) + room = parse(self.parent.parentApp.mainPath / 'gamedata/world' / roomlocation)[ + player.playerData['player']['location']] # If the file could not be found except FileNotFoundError: # Log a critical error! - self.parent.parentApp.log.critical('Handler could not load the current room! Is the player file corrupt or was there a typo? Path was {0}'.format(self.parent.parentApp.mainPath / 'gamedata/world' / roomlocation)) + self.parent.parentApp.log.critical( + 'Handler could not load the current room! Is the player file corrupt or was there a typo? Path was {0}'.format( + self.parent.parentApp.mainPath / 'gamedata/world' / roomlocation)) # Put the player in a blank room i forgot to finish room = parse(self.parent.parentApp.mainPath / 'gamedata/world/blank_room.yaml') # By now we should be situated in our room, and with our player. - if command == '': + self.parent.parentApp.log.debug(room) + + # TODO: Should upgrade these to use fuzzy words library! and not direct comparisons! + if command == 'LOOK': + if arguments[0] == 'AROUND': + try: + self.parent.update_log(room['look_around']) + except KeyError: + self.parent.update_log('There is nothing to look at?.. This might be a bug.') + + if command == 'WHERE': + # TODO: this should take the human readable room name, not the code-name self.parent.update_log('You are in {0}.'.format(room)) # Log the command that we parsed @@ -64,5 +80,5 @@ class Handler(npyscreen.ButtonPress): self.parent.artContent.display() # Switch back to the game menu. - #TODO: possibly deprecate this statement? + # TODO: possibly deprecate this statement? self.parent.parentApp.switchForm('GAME')