01-11-2008, 04:15 PM
Well, damnit... it was a bit confusing so I made my own version of the thing. Commented it a bit so hope you see what I meant.
That's around how I think you meant for it to be but not sure.
Code:
# Shop
import sys
#--- Variables ---
Gold = 0
Choise = ""
#--- End of vars ---
# Loop for the gold thing
while True:
Choise = 0
# User input without cast to int. Could still add the exception but I'm not sure
# can you still screw up the input like this or not.
Choise = raw_input("Please choose from 1 or 2.\n")
if Choise == "1":
print "No, try the other option.\n"
continue # Jumps back to the start of loop without going through the rest
elif Choise == "2":
print "You receive 500 gold."
Gold += 500
print "Now you have", Gold, "gold total.\n"
break # Breaks off the while loop
else:
print "That's not a valid option!\n"
continue
# Shop loop
while True:
Choise = 0
Choise = raw_input("Welcome to my store. Would you like to 'buy' something sir? If not then 'gtfo'\n")
if Choise == "buy":
while 1:
Choise == 0
Choise = raw_input("I only have these items for sale, business has been rather slow lately.\n*You notice him point to a 'sword' and 'shield' collection on the shelves*\n")
if Choise == "shield":
if Gold >= 150: # When you have enough money
Gold -= 150
print "You bought a shield for 150 gold! You have", Gold, "gold left now.\n"
break
else: # ...and when you don't
print "You only have", Gold,"gold! You can't afford that!\n"
break
elif Choise == "sword":
if Gold >= 250:
Gold -= 250
print "You bought a sword for 250 gold! You have", Gold, "gold left now.\n"
break
else:
print "You only have", Gold,"gold! You can't afford that!\n"
break
else:
print "That's not a valid option!\n"
continue
elif Choise == "gtfo":
print "Bye then!\n"
break
else:
print "That's not a valid option!\n"
continue
That's around how I think you meant for it to be but not sure.