Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # Remember to run from your terminal!
- # What's new in version Alpha 1.0.2
- # -provided a fix for users running on windows that actually works.
- from random import randint
- import os, time
- global gold
- global apples
- apples = 1
- gold = 1
- prompt = "> "
- def main():
- global gold
- global apples
- os.system('cls' if os.name == 'nt' else 'clear')
- print "Gold: %r Apples: %r" % (gold, apples)
- print "Pick an apple?"
- choice = raw_input(prompt)
- if choice == "yes":
- pick()
- elif choice == "no":
- os.system('cls' if os.name == 'nt' else 'clear')
- global gold
- global apples
- print "Apples: %r Gold: %r" % (apples, gold)
- print "Sell apples?"
- sell = raw_input(prompt)
- if sell == "yes" and apples >= 1:
- global gold
- global apples
- gold = gold * apples
- apples = apples - apples
- if gold >= 100 ** 100:
- os.system('cls' if os.name == 'nt' else 'clear')
- print "\t\t\tYou won!"
- print "Congrats on controlling the apple market!"
- else:
- time.sleep(0.7)
- main()
- elif sell == "yes" and apples <= 0:
- print "\nNot enough apples!"
- time.sleep(0.7)
- main()
- elif sell == "no":
- main()
- else:
- main()
- elif choice == "exit":
- os.system('cls' if os.name == 'nt' else 'clear')
- print "Bye..."
- else:
- main()
- def pick():
- os.system('cls' if os.name == 'nt' else 'clear')
- global gold
- global apples
- print "Type 0 to exit. How many?"
- print "Apples: %r Gold %r" % (apples, gold)
- try:
- apple_num = int(raw_input(prompt))
- if apple_num == 3 or apple_num == 2 or apple_num == 1:
- global apples
- apples = apples + apple_num
- time.sleep(0.5)
- pick()
- elif apple_num >= 4:
- os.system('cls' if os.name == 'nt' else 'clear')
- print "You can't haul that many apples!"
- time.sleep(0.5)
- pick()
- elif apple_num == 0:
- main()
- except ValueError:
- pick()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement