I am making a python program that is a adventure game thing through a haunted house. One of the big things in it is a list called owned_items. This gets items which are represented by strings like, "box of matches" or "torch" appended to it when they find them in the house or are given to them at the start by random.choice. Sometimes, when they are presented with a situation, what choices they are given is dependent on whether they have a specific item or not. My Code:
def skeleton_choice():
if "a glass bottle" in owned_items:
print('type "glass bottle" to attack the skeletons with that bottle')
if "a pistol" in owned_items and bullets>1:
print('type "shoot" to try firing your pistol at the skeletons')
if "a small knife" in owned_items:
print('type "small knife" to use your small knife against the skeletons')
if "a kitchen knife" in owned_items:
print('Type "kitchen knife" to use your kitchen knife against the skeletons')
if "a blessed amulet" in owned_items:
print('Type "amulet" to use the blessed amulet to make this a fairer fight')
print('Type "hands" to just fight the skeletons with your body')
print('Type "run" to try and get away from the skeletons')
Even when I know that I have 3 of the items in these if statements, none of the prints show up. I'm using ifs rather than elifs and an else because I want it to show the print for everything they have, not just one. For example, if they have a glass bottle and a kitchen knife, I want it to give them the print statements for the bottle and the knife.
Aucun commentaire:
Enregistrer un commentaire