Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time, random, os
- playerName = None
- levels = {
- "1":{"name":"Easy", "points":1, "range":5},
- "2":{"name":"Medium", "points":3, "range":10},
- "3":{"name":"Hard", "points":5, "range":20},
- }
- gifts = {
- "1":{"name": "Candy", "price":1},
- "2":{"name": "Chocolate Bar", "price":5},
- "3":{"name": "Tour To The Moon", "price":10},
- }
- points = 1
- DEBBUG = True
- def main():
- clear_screen()
- print("Hello! This is a simple guess game.")
- time.sleep(2)
- global playerName
- playerName = input("Would you please tell me your name?")
- clear_screen()
- print(f"Well hello {playerName}")
- time.sleep(2)
- main_menu()
- def main_menu():
- clear_screen()
- print(f"Here are your options {playerName}")
- menu = """
- 1. Easy (0-5)
- 2. Medium (0-10)
- 3. Hard (0-10)
- 4. Gift Shop
- 5. Exit game.
- """
- print(menu)
- userInput = input()
- if not userInput in ["1","2","3","4","5"]:
- clear_screen()
- print("Use only the options I gave you silly")
- time.sleep(3)
- main_menu()
- if userInput in ["1", "2","3"]:
- play(userInput)
- elif userInput == "4":
- gift_shop()
- else:
- print(f"See you soon {playerName}!!!!!!")
- time.sleep(3)
- exit()
- def play(level):
- global points
- guess = random.randint(0, levels[level]['range'])
- lives = 3
- clear_screen()
- print(f"You are playing on {levels[level]['name']} level.")
- time.sleep(2)
- if level == "1":
- print("This will be easy for you. It is good for warming up!")
- elif level == "2":
- print("This will be a bit harder.")
- else:
- print(f"You must be a brave one {playerName}, You can earn a lot if you survive!")
- time.sleep(3)
- print(f" On this level you can win {levels[level]['points']} point but you have only {lives} tries!")
- print(f"Be careful!")
- time.sleep(5)
- clear_screen()
- print(f"I guessed a number between 0-{levels [level]['range']}.")
- if DEBBUG:
- print(f"DEBBUG: guess {guess}")
- userGuess = int(input("What is your guess???"))
- while not userGuess == guess:
- clear_screen()
- lives -= 1
- if lives == 0: # ha nem maradt életünk
- print(f"You lost all your points... Maybe baby next time!")
- time.sleep(5)
- main_menu()
- if lives == 1:
- print(f"You have {lives} lives left. This is your last chance!!!")
- else:
- print(f"You have {lives} lives left.")
- userGuess = int(input("What is your next guess?????"))
- clear_screen()
- print(f"Yessss! {userGuess} was my number!")
- print(f"I give you {levels[level]['points']} point(s)")
- points += levels[level]['points']
- print(f" Now You have {points} points.")
- print(f"Please go to the gift shop or play more!")
- time.sleep(5)
- main_menu()
- def gift_shop():
- global points
- clear_screen()
- if points < 1:
- print("You do not have enough points yet!")
- print("Go back and please play a bit more!")
- time.sleep(4)
- main_menu()
- print(f"Dear {playerName}, These are the following items you can buy:")
- available_items = {}
- for key, value in gifts.items():
- if value["price"] <= points:
- available_items[key] = value
- print(f"{key}. {value['name']} price: {value['price']}")
- userInput = input()
- while not userInput in available_items:
- clear_screen()
- print("This item is not in the menu")
- userInput = input()
- clear_screen()
- points -= available_items[userInput]["price"]
- print(f"You bought a {available_items[userInput]['name']}.")
- print(f"You have a {points} points.")
- time.sleep(3)
- main_menu()
- def clear_screen():
- os.system("cls")
- main_menu()
Advertisement
Add Comment
Please, Sign In to add comment