Player can pick up items but cannot yet add them to the inventory.

This commit is contained in:
Joe S 2021-02-24 00:37:54 -05:00
parent 6f10d6420b
commit 3928084098
2 changed files with 18 additions and 1 deletions

View File

@ -75,6 +75,23 @@ class Handler(npyscreen.ButtonPress):
except KeyError: except KeyError:
self.parent.update_log("Not sure what you're trying to look at.") self.parent.update_log("Not sure what you're trying to look at.")
if command == 'PICK':
if arguments[0] == 'UP':
if len(arguments) <= 2: # If there are only 2 args ex:up, item then we dont need to merge that last arg
try:
# Argument[1] is the "thing" you want to pick up, yaml is lowercase so we lowercase it.
self.parent.parentApp.log.info('Player tried to pick up {0}'.format(arguments[1]))
self.parent.update_log(room[arguments[1].lower()]['pick_up'])
except KeyError:
self.parent.update_log("You cant pick that up.")
else: # if its a longer list of args, the player prolly wants to pick up an item with multiple words, like hand_axe, or log_viewer
try:
long_arg = '_'.join(arguments[1:]) # Joins whatever comes after 1 in our args with '_' between
self.parent.parentApp.log.info('Player tried to pick up long object {0}'.format(long_arg))
self.parent.update_log(room[long_arg.lower()]['pick_up'])
except KeyError:
self.parent.update_log("You cant pick that up.")
if command == 'WHERE': if command == 'WHERE':
# TODO: this should take the human readable room name, not the code-name # TODO: this should take the human readable room name, not the code-name
self.parent.update_log('You are in {0}.'.format(room)) self.parent.update_log('You are in {0}.'.format(room))