This is a bare sample of what I'm trying to build and I don't know why the combination of "wallet" and "ring" can pass as win.
I want the player to obtain all three items in order to win. Do you pose better solution to this?
import sys
inventory = []
def addtoInventory(item):
inventory.append(item)
def room():
print('you are in a living room, you say a card. Pick it up?')
pickup = input()
while pickup:
if pickup == 'yes':
addtoInventory("card")
secondroom()
else:
print("you didnt pick it up")
secondroom()
def secondroom():
print('you are now in bedroom, theres a wallet, pick it up?')
pickup = input()
while pickup:
if pickup == 'yes':
addtoInventory("wallet")
bathroom()
else:
print("you didnt pick it up")
bathroom()
def bathroom():
print('you are now in bathroom, theres a ring, pick it up?')
pickup = input()
while pickup:
if pickup == 'yes':
addtoInventory('ring')
mall()
else:
print("you didnt pick it up")
mall()
def mall():
endgame = ["wallet", "card", "ring"]
print('you are about to get a taxi to the pawn shop. do you have everything you need?')
answer = input()
print(inventory)
while answer:
if answer == 'yes':
for item in endgame:
if item not in inventory:
print("you lose")
sys.exit()
else:
print("you won")
sys.exit()
else:
print("you lose")
break
Aucun commentaire:
Enregistrer un commentaire