Advertisement
Guest User

Untitled

a guest
Jan 31st, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.63 KB | None | 0 0
  1. import os
  2.  
  3.         #-----------------------#
  4.         # create default values #
  5.         #-----------------------#
  6.  
  7. workerCost = 100
  8. money = 100
  9. workers = 0
  10. apples = 0
  11. oaApples = 0
  12. oaMoney = 0
  13. difficulty = 0
  14. validDifficulties = [0,1]
  15. menuChoice = 0 # keep here so that while loop (menu) can run
  16.  
  17.         #--------------------#
  18.         # start of menu code #
  19.         #--------------------#
  20.  
  21. while menuChoice != 1:
  22.     print("## Apple Picker ##")
  23.     print("\n(1) Start game")
  24.     print("(2) Change settings")
  25.     print("(3) Change difficulty [Currently {0}]".format(difficulty))
  26.     print("(4) Check current settings")
  27.     print("Enter the choice number.")
  28.     menuChoice = int(input("[>>] "))
  29.  
  30.     validChoices = [1,2,3,4]
  31.     while menuChoice not in validChoices:
  32.         print("That choice is invalid. Try again.")
  33.         print("Enter the choice number.")
  34.         menuChoice = int(input("[>>] "))
  35.  
  36.     if menuChoice == 1:
  37.         os.system('cls')
  38.         print("Starting game...")
  39.         print("\n\nPress any key to start the game.")
  40.         os.system('pause > nul')
  41.         os.system('cls')
  42.  
  43.     elif menuChoice == 2:
  44.         os.system('cls')
  45.         print("What should the worker cost be? [Default: 100]")
  46.         workerCost = int(input("[>>] ")) # change worker cost (still +20 each time worker is bought)
  47.         print("What should the starting money be? [Default: 0]")
  48.         money = int(input("[>>] ")) # change starting money amount from 0 to x
  49.         print("What should be the starting workers be? [Default: 0]")
  50.         workers = int(input("[>>] ")) # change starting workers from 0 to x
  51.         print("What should the starting apples be? [Default: 0]")
  52.         apples= int(input("[>>] ")) # change starting apples from 0 to x (useless)
  53.         print("\n\nPress any key to return to the menu.")
  54.         os.system('pause > nul')
  55.         os.system('cls')
  56.  
  57.     elif menuChoice == 3:
  58.         os.system('cls')
  59.         print("Please choose game difficulty.")
  60.         print("Hard: worker cost increases each time you buy a worker.")
  61.         print("Easy: worker cost stays the same throughout.")
  62.         print("1 = Hard")
  63.         print("0 = Easy")
  64.         difficultyChoice = int(input("[>>] "))
  65.         if difficultyChoice == 1:
  66.             difficulty = 1
  67.             print("Difficulty set to hard. Good luck!")
  68.         elif difficultyChoice == 0:
  69.             difficulty = 0
  70.             print("Difficulty set to easy. Good luck!")
  71.         print("\n\nPress any key to return to the menu.")
  72.         os.system('pause > nul')
  73.         os.system('cls')
  74.  
  75.     elif menuChoice == 4:
  76.         os.system('cls')
  77.         print("Current game settings:")
  78.         print("Worker cost: {0}".format(workerCost))
  79.         print("Starting money: {0}".format(money))
  80.         print("Starting workers: {0}".format(workers))
  81.         print("Starting apples: {0}".format(apples))
  82.         print("\n\nPress any key to return to the menu.")
  83.         os.system('pause > nul')
  84.         os.system('cls')
  85.  
  86.         #------------------#
  87.         # end of menu code #
  88.         #------------------#
  89.  
  90. print("Type 'p' to pick an apple.")
  91. print("Type 's' to sell all apples.")
  92. print("Type 'b' to buy x1 worker.")
  93. print("Type 'q' to quit the game.")
  94.  
  95. while True: # keep this here to run the whole game repeatidly!
  96.  
  97.     choice = input("[>>] ")
  98.     if choice == "p": # apple-pick section
  99.         os.system('cls')
  100.         apples = apples + 1 + workers
  101.         oaApples = oaApples + 1 + workers
  102.         print("You pick an apple. You have {0} apples.".format(apples))
  103.         print("\n\nType 'p' to pick an apple.")
  104.         print("Type 's' to sell all apples.")
  105.         print("Type 'b' to buy x1 worker.")
  106.         print("Type 'q' to quit the game.")
  107.  
  108.     elif choice == "s": # apple-sell section
  109.         os.system('cls')
  110.         money = money + apples * 3
  111.         oaMoney = oaMoney + apples
  112.         apples = 0
  113.         print("You sell all apples. You have ${0}.".format(money))
  114.         print("\n\nType 'p' to pick an apple.")
  115.         print("Type 's' to sell all apples.")
  116.         print("Type 'b' to buy x1 worker.")
  117.         print("Type 'q' to quit the game.")
  118.  
  119.     elif choice == "b": # apple-buy section
  120.         os.system('cls')
  121.         if difficulty == 1: # if the difficulty is set to hard
  122.             if money >= workerCost:
  123.                 workers = workers + 1
  124.                 workerCost = workerCost + 20
  125.                 money = money - workerCost
  126.                 print("You buy a worker for ${0}. You have {1} workers.".format(workerCost,workers))
  127.             elif money < workerCost:
  128.                 print("You don't have enough money for a worker.")
  129.         elif difficulty == 0: # if the difficulty is set to easy
  130.             if money >= workerCost:
  131.                 workers = workers + 1
  132.                 money = money - workerCost
  133.                 print("You buy a worker for ${0}. You have {1} workers.".format(workerCost,workers))
  134.             elif money < workerCost:
  135.                 print("You don't have enough money for a worker.")
  136.         print("\n\nType 'p' to pick an apple.")
  137.         print("Type 's' to sell all apples.")
  138.         print("Type 'b' to buy x1 worker.")
  139.         print("Type 'q' to quit the game.")
  140.  
  141.     elif choice == "q":
  142.         os.system('cls')
  143.         print("Thanks for playing.")
  144.         print("You achieved:")
  145.         print("{0} workers.".format(workers))
  146.         print("{0} over-all money.".format(oaMoney))
  147.         print("{0} over-all apples.".format(oaApples))
  148.         if workers > 200:
  149.             print("You offically have no life.")
  150.         print("\n\nPress any key to quit.")
  151.         os.system('pause > nul')
  152.         exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement