def load_game(): choose_game = int( input(""" Please choose a game to play: 1. Guess Game - a sequence of numbers will appear for 1 second and you have to guess it back 2. Memory Game - guess a number and see if you chose like the computer 3. Currency Roulette - Guess the current temperature currently in Jerusalem Enter Your Choice Here : """)) if CheckChoice(choose_game): choose_difficulty = int( input(" Please choose game difficulty from 1 to 5 : ")) if CheckChoicediff(choose_difficulty): print("Welcome to the Game") if choose_game == 1: print( "You have chosen game GuessGame with difficulty level %s" % (choose_difficulty)) GuessGame.play(choose_difficulty) elif choose_game == 2: print( "You have chosen game MemoryGame with difficulty level %s" % (choose_difficulty)) MemoryGame.play(choose_difficulty) elif choose_game == 3: print( "You have chosen game CurrencyRouletteGame with difficulty level %s" % (choose_difficulty)) CurrencyRouletteGame.play(choose_difficulty) else: print("You Have entered an Incorrect Option!") return -1 else: print("You Have entered an Invalid Option!") return -1
def load_game(): try: game_chosen = int(input("""Please choose a game to play: \n\t1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back 2. Guess Game - guess a number and see if you chose like the computer\n""")) # Check that the user input 1 or 2 and not anything else (e.g. int or string) if 0 < game_chosen < 3: try: difficulty = int(input("\nPlease choose game difficulty from 1 to 5: ")) if difficulty in range(1, 6): if game_chosen == 1: print("\nSTARTING TO PLAY MEMORY GAME") print("------------------------------\n") # Start the Memory game and sends the difficulty level as a parameter for points MemoryGame.play(difficulty) elif game_chosen == 2: print("\nSTARTING TO PLAY GUESS GAME") print("-----------------------------\n") # Start the Guess game and sends the difficulty level as a parameter for points GuessGame.play(difficulty) else: error_messages('1') # Get error message from Utils exit() except ValueError: error_messages('2') # Get error message from Utils exit() pass else: error_messages('3') # Get error message from Utils exit() except ValueError: error_messages('4') # Get error message from Utils exit()
def load_game(): exception = False # Flag to keep info whether exception was thrown or not while exception == False: print( "Please choose a game to play: \n" "\t1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back \n" "\t2. Guess Game - guess a number and see if you chose like the computer \n" ) try: game_choice = int(input(">>>")) if game_choice not in range(1, 3): raise ValueError else: exception = True # The exception was not thrown, so the loop will be finished except ValueError as e: print(Utils.ERROR_MESSAGE()) d_exception = False # Flag to keep info whether exception was thrown or not while d_exception == False: print("Please choose game difficulty from 1 to 5:") try: difficulty_choice = int(input(">>>")) if difficulty_choice not in range(1, 6): raise ValueError else: d_exception = True # The exception was not thrown, so the loop will be finished. except ValueError as e: print(Utils.ERROR_MESSAGE()) if game_choice == 1: MemoryGame.play(difficulty_choice) if game_choice == 2: GuessGame.play(difficulty_choice)
def load_game(): res = input("Please choose a game to play:\n1.Memory Game - a sequence" + " of numbers will appear for 1 second and you have to guess" + " it back\n2.Guess Game - guess a number and see if you" + " chose like the computer\n3.Currency Roulette - " + "try and guess the value of a random amount of USD in ILS\n") while True: # forcing user to submit a valid int response try: turn_to_number = int(res) if 1 <= turn_to_number <= 3: print("good pick") break else: res = input("value needs to be between 1 and 3:") continue except ValueError: res = input( "not a non decimal number or out of range, try again: ") difficulty = input("please select a difficulty level from 1 to 5: ") while True: try: int(difficulty) turn_to_number = int(difficulty) if 1 <= turn_to_number <= 5: print("good pick") break else: difficulty = input("value needs to be between 1 and 5:") continue except ValueError: difficulty = input("not a number, try again:") # from this point i am adding the last part changes from WOG2 # print("result " + res) # print(difficulty) if int(res) == 1: print("memory") MemoryGame.play(int(difficulty)) elif int(res) == 2: GuessGame.play(int(difficulty)) elif int(res) == 3: print("currency") CurrencyRouletteGame.play(int(difficulty)) else: pass
def load_game(): game_num = 0 game_dif = 0 score = 0 while score == 0: while game_num < 1 or game_num > 2: try: game_num = int( input( "1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back.\r\n" "2. Guess Game - guess a number and see if you chose like the computer\r\n" "0. To cancel")) except ValueError as ee: print("Incorrect input. Try again.") if game_num == 0: exit() while game_dif < 1 or game_dif > 5: try: game_dif = int( input("Please choose game difficulty from 1 to 5:")) except ValueError as ee: print("Incorrect input. Try again.") if game_num == 1: score = MemoryGame.play(game_dif) if game_num == 2: score = GuessGame.play(game_dif) if score > 0: score_file = "Scores.txt" Score.add_score(score_file, score) return
def load_game(): print('Please choose a game to play:') print( '1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back' ) print( '2. Guess Game - guess a number and see if you chose like the computer' ) while True: game = input('enter game option 1 or 2:') if game not in ('1', '2'): print(Utils.ERROR_MESSAGE()) print('enter a valid option') continue else: break while True: difficulty = input('enter game Difficulty from 1 to 5:') if difficulty not in ('1', '2', '3', '4', '5'): print(Utils.ERROR_MESSAGE()) print('enter a valid option') continue else: break #casting str from user to int avoid crash if int(game) == 1: result = MemoryGame.play(int(difficulty)) else: result = GuessGame.play(int(difficulty)) #countint score if result == True: count(difficulty) return (result)
def load_game(): title = 'Please choose a game to play:' rul_1 = '1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back' rul_2 = '2. Guess Game - guess a number and see if you chose like the computer' rul_3 = '3. Currency Roulette - try and guess the value of a random amount of USD in ILS' choice = int(input(f'{title} \n\t{rul_1}\n\t{rul_2}\n\t{rul_3}\n')) is_not_choice = True while is_not_choice: if int(choice) > 3 or int(choice) < 1: choice = int( input(f'Please enter the game number (between 1 to 3)' f'\n{title} \n\t{rul_1}\n\t{rul_2}\n\t{rul_3}\n')) else: is_not_choice = False difficulty = int(input('Please choose game difficulty from 1 to 5:\n')) is_not_difficulty = True while is_not_difficulty: if int(difficulty) > 5 or int(difficulty) < 1: difficulty = int( input('Please choose game difficulty from 1 to 5:\n')) else: is_not_difficulty = False if choice == 1: print(MemoryGame.play(difficulty)) elif choice == 2: print(GuessGame.play(difficulty)) elif choice == 3: print(CurrencyRouletteGame.play(difficulty))
def load_game(): import Utils import MemoryGame import GuessGame import Score print( "Please choose a game to play: \n 1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back \n 2. Guess Game - guess a number and see if you chose like the computer" ) choosegame = input() print("Please choose game difficulty from 1 to 5 :") if (choosegame > "2") or (choosegame < "1"): print(Utils.ERROR_MESSAGE), load_game() choosegame = int(choosegame) difficulty = input() if (difficulty > "5") or (difficulty < "1"): print(Utils.ERROR_MESSAGE), load_game() difficulty = int(difficulty) if choosegame == 1: if MemoryGame.play(difficulty) == True: Score.add_score(difficulty) else: load_game() elif choosegame == 2: if GuessGame.play(difficulty) == True: Score.add_score(difficulty) else: load_game()
def load_game(): print(Utils.GAMES_AVAILABLE) # game and difficulty choosing process game_chosen = Utils.validate_user_input(1, 2, "game") difficulty = Utils.validate_user_input(1, 5, "difficulty") game_result = None # running games by user's choice if game_chosen == 1: game_result = MemoryGame.play(difficulty) elif game_chosen == 2: game_result = GuessGame.play(difficulty) # checking weather the user won or lost - Refer to the play method in either GuessGame or MemoryGame if game_result: print("Congratulation! YOU WON") Score.add_score(difficulty) else: print("Close but not quit right") Score.add_score(0) load_game()
def load_game(): game_to_play = int( input( "\nPlease Choose an game to play:\n" "1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back\n" "2. Guess Game - guess a number and see if you chose like the computer\n" "3. Currency Roulette - try and guess the value of a random amount of USD in ILS\n" )) difficulty = int(input("\nPlease choose game difficulty from 1 to 5: ")) if game_to_play not in range(1, 4) or difficulty not in range(1, 5): raise ValueError try: if game_to_play == 1: if MemoryGame.play(difficulty): print("You won the game") Score.add_score(difficulty) else: print("You lose the game") if game_to_play == 2: if GuessGame.play(difficulty): Score.add_score(difficulty) if game_to_play == 3: if CurrencyRouletteGame.play(difficulty): Score.add_score(difficulty) print("\n-------YOU WON THE GAME---------\n") except ValueError: raise ValueError
def load_game(): clean_screen() # print header for game selection print("Please choose a game to play:") print("1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back") print("2. Guess Game - guess a number and see if you chose like the computer") print("3. Currency Roulette - try and guess the value of a random amount of USD in ILS") print("Enter Selection:") while (True): try: game_slected = int(input()) if ( game_slected <= 3 and game_slected >= 1): break else: raise ValueError() except ValueError: print("Must be a number between 1 to 3 !!") clean_screen() print("Please choose game difficulty from 1 to 5:") print("Enter Selection:") while (True): try: diff = int(input()) if (diff < 1 or diff > 5): os.system('cls') raise ValueError() else: os.system('cls') break except ValueError: print("Must be a number between 1 to 5 !!") if game_slected == 1: memory_game = MemoryGame(diff) if (memory_game.play()): print("Yeeppee... YOU WON") print("Updating score file...") add_score(diff) else: print("Sorry... YOU LOSE") elif game_slected == 2: guess_game = GuessGame(diff) if (guess_game.play()): print("Yeeppee... YOU WON") print("Updating score file...") add_score(diff) else: print("Sorry... YOU LOSE") elif game_slected == 3: currency_game = CurrencyRouletteGame(diff) if (currency_game.play()): print("Yeeppee... YOU WON") print("Updating score file...") add_score(diff) else: print("Sorry... YOU LOSE")
def load_game(): Game = raw_input( "Please choose a game to play:" "1. Memory Game - a sequence of numbers will appear for 1 second and you have toguess it back" "2. Guess Game - guess a number and see if you chose like the computer" "3. Currency Roulette - try and guess the value of a random amount of USD in ILS, " ) if Game != '': GameNumber = int(Game) if GameNumber >= 1 and GameNumber <= 3: Difficulty = int( raw_input("Please choose game difficulty from 1 to 5:")) if Difficulty >= 1 and Difficulty <= 5: if GameNumber == 1: Answer = MemoryGame.play(Difficulty) if Answer: Score.add_score(Difficulty) print("You were right") Utils.Screen_cleaner() load_game() else: print("You were wrong") Utils.Screen_cleaner() load_game() if GameNumber == 2: Answer = GuessGame.play(Difficulty) if Answer: print("You Right") Score.add_score(Difficulty) Utils.Screen_cleaner() load_game() else: print("You not Right") Utils.Screen_cleaner() load_game() if GameNumber == 3: Answer = CurrencyRouletteGame.play(Difficulty) if Answer: print("you right") Score.add_score(Difficulty) Utils.Screen_cleaner() load_game() else: Utils.Screen_cleaner() load_game() else: print( "you choose worng number for difficulty choose right one") load_game() else: print("you choose wrong number Please Choose right one") load_game() else: print("print Any Number") load_game()
def load_game(): select_game() select_game_difficulty() if game_name == games_names_list[0]: if MemoryGame.play(game_difficulty): Scores.add_score(game_difficulty) elif game_name == games_names_list[1]: if GuessGame.play(game_difficulty): Scores.add_score(game_difficulty) elif game_name == games_names_list[2]: if CurrencyRouletteGame.play(game_difficulty): Scores.add_score(game_difficulty)
def load_game(): chosen_game = int( input( 'Please choose a game to play:' ' 1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back' ' 2. Guess Game - guess a number and see if you chose like the computer' )) if chosen_game < 1 or chosen_game > 2: return ERROR_MESSAGE level_of_difficulty = int( input('Please choose game difficulty from 1 to 5:')) if level_of_difficulty < 1 or level_of_difficulty > 5: return ERROR_MESSAGE if chosen_game == 1: MemoryGame.play(level_of_difficulty) elif chosen_game == 2: GuessGame.play(level_of_difficulty)
def load_game(): #ask the user to choose a game try: input_game = ( "Please choose a game to play:\n" "1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back\n" "2. Guess Game - guess a number and see if you chose like the computer" ) game_chosen = int(input(input_game)) except: game_chosen = 0 while (game_chosen != 1 and game_chosen != 2): print(ERROR_MESSAGE) try: game_chosen = int(input(input_game)) except: game_chosen = 0 #ask the user to choose the difficulty try: input_difficulty = "Please choose game difficulty from 1 to 5:" difficulty_chosen = int(input(input_difficulty)) except: difficulty_chosen = 0 difficulty_list = [1, 2, 3, 4, 5] while (difficulty_chosen not in difficulty_list): try: print(ERROR_MESSAGE) difficulty_chosen = int( input("Please choose game difficulty from 1 to 5:")) except: difficulty_chosen = 0 #play the MemoryGame if (game_chosen == 1): game_result = MemoryGame.play(difficulty_chosen) if (game_result == True): add_score(difficulty_chosen) print("Well done, your score in this game is: " + str(difficulty_chosen)) else: print("Let's try again") load_game() #play the GuessGame elif (game_chosen == 2): game_result = GuessGame.play(difficulty_chosen) if (game_result == True): add_score(difficulty_chosen) print("Well done, your score is: " + str(difficulty_chosen)) else: print("Let's try again") load_game()
def load_game(): game_num = 0 while game_num != 1 and game_num != 2: try: game_num = int( input( "Please choose a game to play:\n1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back\n2. Guess Game - guess a number and see if you chose like the computer\n" )) except ValueError: print(ERROR_MESSAGE) difficulty = 0 while difficulty > 5 or difficulty < 1: try: difficulty = int( input("Please choose game difficulty from 1 to 5:")) except ValueError: print(ERROR_MESSAGE) if game_num == 1: MemoryGame.play(difficulty) elif game_num == 2: GuessGame.play(difficulty)
def load_game(): welcome() difficulty = game_difficulty() print( "Please choose a game to play:\n" "1. Memory game - a sequence of numbers will appear for 1 second and you have to guess it back.\n" "2. Guess Game - guess a number and see if you choose like the computer.\n" "3. Currency Roulette - try and guess the value of a random amount of USD in ILS.\n" ) game_number = int(input("Your choice:\n")) while game_number > 3: print("Input should be a number between 1 - 3\n") game_number = int(input("Your choice:\n")) if game_number == 1: MemoryGame.play(difficulty) elif game_number == 2: GuassGame.play(difficulty) else: CurrencyRouletteGame.play(difficulty)
def load_game(): print( "Please choose a game to play: \n 1. Memory Game - a sequence of numbers will appear for 1 second and you " "have to guess it back. \n 2. Guess Game - guess a number and see if you chose like the computer" ) error = Utils.ERROR_MESSAGE try: chosen_game = int(input()) while chosen_game != 1 and chosen_game != 2: print(error + " - You have two options only (1 or 2).") chosen_game = int(input()) print("Please choose game difficulty from 1 to 5:") game_dif = int(input()) while game_dif < 1 or game_dif > 5: print(error + " - Game difficulty must be between 1 to 5.") game_dif = int(input()) if chosen_game == 1: MemoryGame.play(game_dif) elif chosen_game == 2: GuessGame.play(game_dif) except (ValueError, UnboundLocalError): print(error + " - You must enter numbers only.")
def load_game(): # Open the main menu, to the game selection # decision : the game number the player choose # difficulty : the number of difficulty the player choose print("""Please choose a game to play: 1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back 2. Guess Game - guess a number and see if you chose like the computer 3. Currency Roulette - try and guess the value of a random amount of USD in ILS""" ) while True: try: decision = int(input("Please insert a number between 1 - 3: ")) while 3 < decision or decision < 1: decision = int(input("Please insert a number between 1 - 3: ")) difficulty = int( input('Please choose game difficulty from 1 to 5:')) while 5 < difficulty or difficulty < 1: difficulty = int( input("Please insert a number between 1 - 5: ")) except ValueError: print( "Error: Enter just numbers please, not letters, words ,etc...") continue if decision == 1: # Calling Game number one (Guess game) GuessGame.play(difficulty) if bool(GuessGame) is True: add_score(difficulty=difficulty) if decision == 2: # Calling Game number Two (Memory game) MemoryGame.play(difficulty) if bool(MemoryGame) is True: add_score(difficulty=difficulty) if decision == 3: # Calling Game number Two (CurrencyRoulette Game) CurrencyRouletteGame.play(difficulty) if bool(CurrencyRouletteGame) is True: add_score(difficulty=difficulty) return difficulty, decision
def load_game(): print("\nPlease choose a game to play: ") print( "1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back" ) print( "2. Guess Game - guess a number and see if you chose like the computer" ) print( "3. Currency Roulette - try and guess the value of a random amount of USD in ILS" ) global game_number game_number = input("\nEnter a game number here please:)") try: check_range(1, 3, int(game_number)) except ValueError as e: print("Please enter a number") sleep(1) load_game() print("Good Choice!!") print("Please choose game difficulty from 1 to 5:") global difficulty_number difficulty_number = input() try: check_range(1, 5, int(difficulty_number)) except ValueError as e: print("Please enter a number") sleep(1) load_game() print("Alright let's begin!!") if game_number == "1": MemoryGame.play(difficulty_number) elif game_number == "2": Guess_Game.play(difficulty_number) elif game_number == "3": print("game-3") else: print("else")
def loadgame(self): game_type = input(""" Please choose a game to play: 1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back 2. Guess Game - guess a number and see if you chose like the computer 3. Currency Roulette - try and guess the value of a random amount of USD in ILS Write Your answer here : """) if (int(game_type) >= 1 and int(game_type) <= 3): game_difficulty = int(self.get_game_difficulty()) if int(game_type) == 1: MemoryGame == MemoryGame() MemoryGame.play(game_difficulty) elif int(game_type) == 2: GuessGame == GuessGame() GuessGame.play(game_difficulty) else: print("print number that i want you to print") self.loadgame()
def load_game(): no_exception = False # Flag to keep info whether exception was thrown or not while no_exception == False: print( "Please choose a game to play: \n" "\t1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back \n" "\t2. Guess Game - guess a number and see if you chose like the computer \n" "\t3. Currency Roulette - try and guess the value of a random amount of USD in ILS" ) try: user__game_choice = int(input(">>>")) if user__game_choice not in range(1, 4): raise ValueError else: no_exception = True # The exception was not thrown, so the loop will be finished. except ValueError as e: print( "\t\t!!!!!!!!!!!!!!! Numbers 1, 2, 3 are only allowed !!!!!!!!!!!!!!!!!\n" ) no_exception = False # Flag to keep info whether exception was thrown or not while no_exception == False: print("Please choose game difficulty from 1 to 5:") try: user__dificulty_choice = int(input(">>>")) if user__dificulty_choice not in range(1, 6): raise ValueError else: no_exception = True # The exception was not thrown, so the loop will be finished. except ValueError as e: print( "\t\t!!!!!!!!!!!!!!! Numbers from 1 to 5 are only allowed !!!!!!!!!!!!!!!!!\n" ) if user__game_choice == 2: GuessGame.set_difficulty(user__dificulty_choice) result = GuessGame.play() elif user__game_choice == 1: MemoryGame.set_difficulty(user__dificulty_choice) result = MemoryGame.play() elif user__game_choice == 3: CurrencyRouletteGame.set_difficulty(user__dificulty_choice) result = CurrencyRouletteGame.play() if result == True: print(" You won") Score.add_score(user__dificulty_choice) else: print(" You lost") Score.create_zero_score()
def load_game(): # user choose game and difficulty game_to_play = int( input( "Please choose a game to play: \n1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back \n2. Guess Game - guess a number and see if you chose like the computer" )) difficulty = int(input("Please choose game difficulty from 1 to 5:")) # calling the games if game_to_play == 1: result = MemoryGame.play(difficulty) elif game_to_play == 2: result = GuessGame.play(difficulty) else: print(BAD_RETURN_CODE) # wright score to score.txt if result == True: Score.add_score(difficulty)
def load_game(): print("Please choose a game to play:") game = int(input(" 1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back\n\ 2. Guess Game - guess a number and see if you chose like the computer\n\ 3. Currency Roulette - tryand guess the value of a random amount of USD in ILS\n\ choose 1/2/3\n")) difficulty = int(input("choose difficulty level (1-5):\n")) if game == 1: win = MemoryGame.play(difficulty) elif game == 2: win = GuessGame.play(difficulty) elif game == 3: win = CurrencyRouletteGame.play(difficulty) Score.add_score(difficulty) return win
def load_game(): flag = True while flag: game = input("""Please choose a game to play: 1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back 2. Guess Game - guess a number and see if you chose like the computer 3. Currency Roulette - try and guess the value of a random amount of USD in ILS Your choice: """) is_digit = game.isdigit() if is_digit: game = int(game) if 1 <= game <= 3: flag = False flag = True while flag: difficulty = input("Please choose game difficulty from 1 to 5: ") is_digit = difficulty.isdigit() if is_digit: difficulty = int(difficulty) if 1 <= difficulty <= 5: flag = False game_result = False if game == 1: game_result = MemoryGame.play(difficulty) elif game == 2: game_result = GuessGame.play(difficulty) else: game_result = CurrencyRouletteGame.play(difficulty) if game_result: add_score(difficulty) print("You have won") else: print("You have lost")
def load_game(): name = input("Please Enter your name: ") print(welcome(name)) print( "1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back" ) print( "2. Guess Game - guess a number and see if you chose like the computer" ) print( "3. Currency Roulette - try and guess the value of a random amount of USD in ILS" ) while True: game = input("Please choose a game to play (1-3):") difficulty = input("Please choose difficulty (1-5):") if game not in ['1', '2', '3' ] or difficulty not in ['1', '2', '3', '4', '5']: print("Invalid selection. Please try again") continue else: if game == '1': if MemoryGame.play(int(difficulty)): Score.add_score((int(difficulty) * 3) + 5) elif game == '2': if GuessGame.play(int(difficulty)): Score.add_score((int(difficulty) * 3) + 5) else: if CurrencyRouletteGame.play(int(difficulty)): Score.add_score((int(difficulty) * 3) + 5) response = input("Do you want to play again (y/n)?") if response == 'y': Utils.screen_cleaner() continue else: print("Goodbye") os.remove('scores.txt') break
def load_game(): str = "\nPlease choose a game to play: \n" str += " 1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back\n" str += " 2. Guess Game - guess a number and see if you chose like the computer\n" game = input(str) if (game != "1") and (game != "2"): print(Utils.error_message()) return #print(game) difficulty = int(input("\nPlease choose game difficulty from 1 to 5:\n")) if (difficulty < 1) or (difficulty > 5): print(Utils.error_message()) return #print(difficulty) if game == "1": #print("chose memory") answer = MemoryGame.play(difficulty) #print(answer) if answer: print("you won {} points".format(difficulty)) add_score(difficulty) load_game() else: print("you lost") load_game() elif game == "2": #print("chose guess") answer = GuessGame.play(difficulty) #print(answer) if answer: print("you won {} points".format(difficulty)) add_score(difficulty) load_game() else: print("you lost") load_game()
def load_game(): try: print( 'Please choose a game to play:\n\t1. Memory Game - a sequence of numbers will appear for 1 second and you ' 'have to guess it back\n\t2. Guess Game - guess a number and see if you chose like the computer') choice = input('Please choose a game to play: ') assert choice in ['1', '2'] difficulty = input('Please choose game difficulty from 1 to 5: ') assert difficulty in ['1', '2', '3', '4', '5'] if int(choice) == 1: if MemoryGame.play(int(difficulty)): Score.add_score(int(difficulty)) else: load_game() else: if GuessGame.play(int(difficulty)): Score.add_score(int(difficulty)) else: load_game() except AssertionError: print(error)
class MainGame: welcome(name=input("Please Enter You Name:" + "\n")) game_number = load_game() difficulty = choose_level() if int(game_number) == 1: MemoryGame.play(difficulty) elif int(game_number) == 2: GuessGame.play(difficulty) elif int(game_number) == 3: CurrencyRouletteGame.play(difficulty) #print result and add score if status: add_score(game_difficulty, user_name) print("Great job , you won") else: print("You lost , try again") p_continue = input("do you want to play again y or n ?")
def load_game(): print("Please choose a game to play:") print( "1. Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back" ) print( "2. Guess Game - guess a number and see if you chose like the computer" ) print( "3. Currency Roulette - try and guess the value of a random amount of USD in ILS" ) game_number = int(input("")) global difficulty difficulty = int(input("Please choose game difficulty from 1 to 5:")) if not (0 < game_number < 4): print("Please re-enter a game number") if not 0 < difficulty < 6: print("Please re-enter a game level") if game_number == 1: print(MemoryGame.play(difficulty)) if game_number == 2: print(GuessGame.play(difficulty)) if game_number == 3: print(CurrencyRouletteGame.play(difficulty))