Advertisement
DatCoderGuy

Apple Picker: Release-Alpha 1.0.2

May 12th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.95 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # Remember to run from your terminal!
  3.  
  4. # What's new in version Alpha 1.0.2
  5. # -provided a fix for users running on windows that actually works.
  6.  
  7.  
  8. from random import randint
  9. import os, time
  10.  
  11. global gold
  12. global apples
  13. apples = 1
  14. gold = 1
  15.  
  16. prompt = "> "
  17.  
  18. def main():
  19.     global gold
  20.     global apples
  21.     os.system('cls' if os.name == 'nt' else 'clear')
  22.     print "Gold: %r Apples: %r" % (gold, apples)
  23.     print "Pick an apple?"
  24.     choice = raw_input(prompt)
  25.     if choice == "yes":
  26.     pick()
  27.     elif choice == "no":
  28.     os.system('cls' if os.name == 'nt' else 'clear')
  29.     global gold
  30.     global apples
  31.     print "Apples: %r Gold: %r" % (apples, gold)
  32.     print "Sell apples?"
  33.     sell = raw_input(prompt)
  34.     if sell == "yes" and apples >= 1:
  35.         global gold
  36.         global apples
  37.         gold = gold * apples
  38.         apples = apples - apples
  39.         if gold >= 100 ** 100:
  40.         os.system('cls' if os.name == 'nt' else 'clear')
  41.         print "\t\t\tYou won!"
  42.         print "Congrats on controlling the apple market!"
  43.         else:
  44.         time.sleep(0.7)
  45.             main()
  46.     elif sell == "yes" and apples <= 0:
  47.         print "\nNot enough apples!"
  48.         time.sleep(0.7)
  49.         main()
  50.     elif sell == "no":
  51.         main()
  52.     else:
  53.         main()
  54.     elif choice == "exit":
  55.     os.system('cls' if os.name == 'nt' else 'clear')
  56.         print "Bye..."
  57.     else:
  58.     main()
  59.  
  60. def pick():
  61.     os.system('cls' if os.name == 'nt' else 'clear')
  62.     global gold
  63.     global apples
  64.     print "Type 0 to exit. How many?"
  65.     print "Apples: %r Gold %r" % (apples, gold)
  66.     try:
  67.     apple_num = int(raw_input(prompt))
  68.     if apple_num == 3 or apple_num == 2 or apple_num == 1:
  69.         global apples
  70.         apples = apples + apple_num
  71.         time.sleep(0.5)
  72.         pick()
  73.         elif apple_num >= 4:
  74.         os.system('cls' if os.name == 'nt' else 'clear')
  75.         print "You can't haul that many apples!"
  76.         time.sleep(0.5)
  77.         pick()
  78.     elif apple_num == 0:
  79.         main()
  80.     except ValueError:
  81.     pick()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement