Obviously, it doesn't work. So what I'm trying to do (this is all very rough at the moment, merely an experiment/test to see if I can get it to work) is have a method under the player class that, when called, takes the value of the requested item, sees if it exists and is valid (which works), and then if both are true then executes the use method on the target item. The problem is, I can't figure out how to pass the name of the desired item in the player's list inventory without it being a string.
Sorry if this is a really nooby mistake. All criticism welcome.
class player():
def __init__(self):
self.inv = []
self.health = 10
def hurt(self):
print "Hurting player for 1 damage."
self.health =- 1
def use(self):
usein = raw_input("Use what? >> ")
if self.inv.count(usein) < 1:
print "Item doesn't exist!"
elif usein is int:
print "Items aren't numbers!"
else:
usein.use()
self.inv.remove(usein)
def print_inv(self):
slot1 = self.inv[0]
print "1. ", slot1," ", self.inv.count(slot1)
class apple():
def __init__(self):
self.weight = 5
self.value = 2
self.hp_restore = 1
def new_apple(self):
bob.inv.append("apple")
def use(self):
bob.health += self.hp_restore