Add (most) of a handler for OPEN command
TODO: finish by updating the player locatio
This commit is contained in:
parent
f400a4c7c3
commit
377bb43e42
|
@ -29,6 +29,13 @@ class GameNavigator(npyscreen.FormBaseNew):
|
||||||
|
|
||||||
self.logBox.value = res # Set the logbox to that value
|
self.logBox.value = res # Set the logbox to that value
|
||||||
|
|
||||||
|
def update_location(self, location):
|
||||||
|
"""
|
||||||
|
This may not be needed in the future, dynamic
|
||||||
|
handling of location is something the navigator should do and should inherit from player.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
top_division_height = 20
|
top_division_height = 20
|
||||||
inventory_width = 20
|
inventory_width = 20
|
||||||
|
|
|
@ -92,6 +92,17 @@ class Handler(npyscreen.ButtonPress):
|
||||||
self.parent.update_log(room[long_arg.lower()]['pick_up'])
|
self.parent.update_log(room[long_arg.lower()]['pick_up'])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.parent.update_log("You cant pick that up.")
|
self.parent.update_log("You cant pick that up.")
|
||||||
|
|
||||||
|
elif command == 'OPEN':
|
||||||
|
try:
|
||||||
|
self.parent.parentApp.log.info('Player tried to open door: {0}'.format(arguments[0]))
|
||||||
|
new_room = room[arguments[0].lower()]['leads_to']
|
||||||
|
self.parent.parentApp.log.debug('New room is: {0}'.format(new_room))
|
||||||
|
except KeyError:
|
||||||
|
self.parent.update_log("You cant open that.")
|
||||||
|
except IndexError:
|
||||||
|
self.parent.update_log("you must specify something to open")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.parent.parentApp.log.info('Player\'s command was not understood: {0}'.format(command))
|
self.parent.parentApp.log.info('Player\'s command was not understood: {0}'.format(command))
|
||||||
self.parent.update_log('I didn\'t understand {0}'.format(command))
|
self.parent.update_log('I didn\'t understand {0}'.format(command))
|
||||||
|
|
|
@ -8,4 +8,11 @@ class Player:
|
||||||
def __init__(self, save_location):
|
def __init__(self, save_location):
|
||||||
self.save_location = save_location
|
self.save_location = save_location
|
||||||
|
|
||||||
self.playerData = parse(save_location)
|
self.playerData = parse(save_location)
|
||||||
|
|
||||||
|
def change_room(self, new_room):
|
||||||
|
"""
|
||||||
|
Should move the player to a new room
|
||||||
|
TODO: Put a check here that checks if the room we're moving to exists!
|
||||||
|
"""
|
||||||
|
self.playerData['player']['location'] = new_room
|
Loading…
Reference in New Issue