Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

See through a Gm's eyes!
#24

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.

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.


Messages In This Thread
See through a Gm's eyes! - by Galens - 01-10-2008, 12:32 PM
See through a Gm's eyes! - by imported_Kitiara - 01-10-2008, 01:27 PM
See through a Gm's eyes! - by imported_KYO1 - 01-10-2008, 01:38 PM
See through a Gm's eyes! - by Galens - 01-10-2008, 02:09 PM
See through a Gm's eyes! - by imported_Nasir - 01-10-2008, 04:55 PM
See through a Gm's eyes! - by imported_Lederoil - 01-10-2008, 05:23 PM
See through a Gm's eyes! - by imported_Aghast - 01-10-2008, 05:37 PM
See through a Gm's eyes! - by imported_Hate - 01-10-2008, 06:40 PM
See through a Gm's eyes! - by imported_ShadarWar - 01-10-2008, 07:37 PM
See through a Gm's eyes! - by imported_ScareCrow - 01-10-2008, 08:29 PM
See through a Gm's eyes! - by imported_Vulcan - 01-10-2008, 09:09 PM
See through a Gm's eyes! - by Galens - 01-10-2008, 10:34 PM
See through a Gm's eyes! - by imported_Kitiara - 01-10-2008, 11:03 PM
See through a Gm's eyes! - by Galens - 01-10-2008, 11:16 PM
See through a Gm's eyes! - by imported_KYO1 - 01-11-2008, 01:50 AM
See through a Gm's eyes! - by Galens - 01-11-2008, 02:13 AM
See through a Gm's eyes! - by imported_Kamos - 01-11-2008, 05:59 AM
See through a Gm's eyes! - by Galens - 01-11-2008, 07:22 AM
See through a Gm's eyes! - by imported_Odium - 01-11-2008, 07:39 AM
See through a Gm's eyes! - by Eighty Swords - 01-11-2008, 07:54 AM
See through a Gm's eyes! - by imported_ScareCrow - 01-11-2008, 08:29 AM
See through a Gm's eyes! - by Galens - 01-11-2008, 10:48 AM
See through a Gm's eyes! - by imported_Kamos - 01-11-2008, 03:53 PM
See through a Gm's eyes! - by imported_Kamos - 01-11-2008, 04:15 PM
See through a Gm's eyes! - by Galens - 01-11-2008, 04:58 PM
See through a Gm's eyes! - by imported_Aghast - 01-11-2008, 05:25 PM
See through a Gm's eyes! - by Eighty Swords - 01-11-2008, 08:39 PM
See through a Gm's eyes! - by imported_LudaKrishna - 01-16-2008, 01:12 AM

Forum Jump:


Users browsing this thread: 6 Guest(s)