+ butaba.health += 25
+ if butaba.health > butaba.MAXHEALTH:
+ butaba.health = butaba.MAXHEALTH
+
+class Chest (GameObject):
+ def __init__ (self, row, col, text, image, key_id, locked = False, items = []):
+ self.key_id = key_id
+ self.locked = locked
+ self.items = items
+ GameObject.__init__ (self, row, col, text, image, False)
+
+ # no interaction with this object. Also solid so return False
+ def interact (self):
+ # object is solid
+ return False
+
+ # try to use the key passed to it
+ def use (self, key):
+ # if chest is locked try to unlock it
+ if self.locked is True:
+ # if the item is a key
+ if isinstance (key, Key):
+ # if the key fits the lock
+ # unlock the chest
+ if key.key_id == self.key_id:
+ self.locked = False
+ # return the key
+ return key
+ # return None if not a key or key did not fit
+ return None
+ else:
+ return self.locked