from yaml_parser import parse_datafile as parse from errors import ItemAlreadyTaken class Player: """ This class intended to abstract out the actual yaml data into a player.(item) that is more friendly to handle in code. """ def __init__(self, save_location): self.save_location = 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 room = self.playerData['player']['location'] return parse('adventure_game/gamedata/world/' + room)['room']['upon_enter'] def add_inventory(self, item): if item in self.playerData['player']['inventory']: raise ItemAlreadyTaken else: self.playerData['player']['inventory'].append(item) def remove_inventory(self, item): pass