Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- #-----------------------#
- # create default values #
- #-----------------------#
- workerCost = 100
- money = 100
- workers = 0
- apples = 0
- oaApples = 0
- oaMoney = 0
- difficulty = 0
- validDifficulties = [0,1]
- menuChoice = 0 # keep here so that while loop (menu) can run
- #--------------------#
- # start of menu code #
- #--------------------#
- while menuChoice != 1:
- print("## Apple Picker ##")
- print("\n(1) Start game")
- print("(2) Change settings")
- print("(3) Change difficulty [Currently {0}]".format(difficulty))
- print("(4) Check current settings")
- print("Enter the choice number.")
- menuChoice = int(input("[>>] "))
- validChoices = [1,2,3,4]
- while menuChoice not in validChoices:
- print("That choice is invalid. Try again.")
- print("Enter the choice number.")
- menuChoice = int(input("[>>] "))
- if menuChoice == 1:
- os.system('cls')
- print("Starting game...")
- print("\n\nPress any key to start the game.")
- os.system('pause > nul')
- os.system('cls')
- elif menuChoice == 2:
- os.system('cls')
- print("What should the worker cost be? [Default: 100]")
- workerCost = int(input("[>>] ")) # change worker cost (still +20 each time worker is bought)
- print("What should the starting money be? [Default: 0]")
- money = int(input("[>>] ")) # change starting money amount from 0 to x
- print("What should be the starting workers be? [Default: 0]")
- workers = int(input("[>>] ")) # change starting workers from 0 to x
- print("What should the starting apples be? [Default: 0]")
- apples= int(input("[>>] ")) # change starting apples from 0 to x (useless)
- print("\n\nPress any key to return to the menu.")
- os.system('pause > nul')
- os.system('cls')
- elif menuChoice == 3:
- os.system('cls')
- print("Please choose game difficulty.")
- print("Hard: worker cost increases each time you buy a worker.")
- print("Easy: worker cost stays the same throughout.")
- print("1 = Hard")
- print("0 = Easy")
- difficultyChoice = int(input("[>>] "))
- if difficultyChoice == 1:
- difficulty = 1
- print("Difficulty set to hard. Good luck!")
- elif difficultyChoice == 0:
- difficulty = 0
- print("Difficulty set to easy. Good luck!")
- print("\n\nPress any key to return to the menu.")
- os.system('pause > nul')
- os.system('cls')
- elif menuChoice == 4:
- os.system('cls')
- print("Current game settings:")
- print("Worker cost: {0}".format(workerCost))
- print("Starting money: {0}".format(money))
- print("Starting workers: {0}".format(workers))
- print("Starting apples: {0}".format(apples))
- print("\n\nPress any key to return to the menu.")
- os.system('pause > nul')
- os.system('cls')
- #------------------#
- # end of menu code #
- #------------------#
- print("Type 'p' to pick an apple.")
- print("Type 's' to sell all apples.")
- print("Type 'b' to buy x1 worker.")
- print("Type 'q' to quit the game.")
- while True: # keep this here to run the whole game repeatidly!
- choice = input("[>>] ")
- if choice == "p": # apple-pick section
- os.system('cls')
- apples = apples + 1 + workers
- oaApples = oaApples + 1 + workers
- print("You pick an apple. You have {0} apples.".format(apples))
- print("\n\nType 'p' to pick an apple.")
- print("Type 's' to sell all apples.")
- print("Type 'b' to buy x1 worker.")
- print("Type 'q' to quit the game.")
- elif choice == "s": # apple-sell section
- os.system('cls')
- money = money + apples * 3
- oaMoney = oaMoney + apples
- apples = 0
- print("You sell all apples. You have ${0}.".format(money))
- print("\n\nType 'p' to pick an apple.")
- print("Type 's' to sell all apples.")
- print("Type 'b' to buy x1 worker.")
- print("Type 'q' to quit the game.")
- elif choice == "b": # apple-buy section
- os.system('cls')
- if difficulty == 1: # if the difficulty is set to hard
- if money >= workerCost:
- workers = workers + 1
- workerCost = workerCost + 20
- money = money - workerCost
- print("You buy a worker for ${0}. You have {1} workers.".format(workerCost,workers))
- elif money < workerCost:
- print("You don't have enough money for a worker.")
- elif difficulty == 0: # if the difficulty is set to easy
- if money >= workerCost:
- workers = workers + 1
- money = money - workerCost
- print("You buy a worker for ${0}. You have {1} workers.".format(workerCost,workers))
- elif money < workerCost:
- print("You don't have enough money for a worker.")
- print("\n\nType 'p' to pick an apple.")
- print("Type 's' to sell all apples.")
- print("Type 'b' to buy x1 worker.")
- print("Type 'q' to quit the game.")
- elif choice == "q":
- os.system('cls')
- print("Thanks for playing.")
- print("You achieved:")
- print("{0} workers.".format(workers))
- print("{0} over-all money.".format(oaMoney))
- print("{0} over-all apples.".format(oaApples))
- if workers > 200:
- print("You offically have no life.")
- print("\n\nPress any key to quit.")
- os.system('pause > nul')
- exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement