def load_game(): arr_games = [] arr_games.append( "Memory Game - a sequence of numbers will appear for 1 second and you have to guess it back" ) arr_games.append( "Guess Game - guess a number and see if you chose like the computer") arr_games.append( "Currency Roulette - try and guess the value of a random amount of USD in ILS" ) gCount = 1 game_win = False # print all games print("Please choose a game to play:") for game in arr_games: print(str(gCount) + ". " + game) gCount += 1 # ask user to choose game chosen_game = str(input("Choose a game:")) while True: if chosen_game.isdigit() == True: if int(chosen_game) in range(1, 4): # check game level # --------------------------------------------------------------------------- game_level = input( "Please choose game difficulty from 1 to 5:") while True: if game_level.isdigit() == True: if int(game_level) in range(1, 6): # clear screen screen_cleaner() print("Lets play Game " + str(chosen_game) + " Level " + str(game_level) + "...") # run game if int(chosen_game) == 1: game_win = play_memory_game(game_level) if game_win: score_server() elif int(chosen_game) == 2: game_win = play_guess_game(game_level) if game_win: score_server() elif int(chosen_game) == 3: game_win = play_roulette_game(game_level) if game_win: score_server() break print("Level not Exist! Try again.") game_level = input( "Please choose game difficulty from 1 to 5:") # --------------------------------------------------------------------------- break print("Game not Exist! Try again.") chosen_game = str(input("Choose a game:"))
def load_game(): game_to_play = "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" \ "3. Currency Roulette - try and guess the value of a random amount of USD in ILS\n" game_to_play_range = range(1, 4) game_to_play_error_msg = "Game to play should be a number between 1 to 3\n" difficulty_level = "Please choose game difficulty from 1 to 5: " game_difficulty_level_error_msg = "Difficulty level should be a number between 1 to 5\n" chosen_game = Utils.get_input_and_check_if_valid(game_to_play, game_to_play_range, game_to_play_error_msg) difficulty_level = Utils.get_input_and_check_if_valid( difficulty_level, Utils.GAME_DIFFICULTY_LEVEL_RANGE, game_difficulty_level_error_msg) if chosen_game == 1: play_memory_game(difficulty_level) Score.add_score(difficulty_level) elif chosen_game == 2: play_guess_game(difficulty_level) Score.add_score(difficulty_level) elif chosen_game == 3: play_currency_game(difficulty_level) Score.add_score(difficulty_level)
def load_game(): 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""") game_number = only_numbers(["Enter here the game number: ", 1, 3]) game_difficulty = only_numbers(["Please choose game difficulty from 1 to 5: ", 1, 5]) if game_number == 1: if play_memory_game(game_difficulty): add_score(game_difficulty) if game_number == 2: if play_guess_game(game_difficulty): add_score(game_difficulty) if game_number == 3: if play_currency_roulette_game(game_difficulty): add_score(game_difficulty)
def start_game(game, difficulty): if (difficulty < 1 or difficulty > 5): # invalid difficulty input return ERROR_MESSAGE elif game == 1: # user want to play the memory game won = play_memory_game(difficulty) elif game == 2: # user want to play the guess game won = play_guess_game(difficulty) else: # invalid game input return ERROR_MESSAGE if won: # add winning score to the user in case he won the game add_score(difficulty) # NOTE: # according to diagram in the project specification it should call load_game function no mather what the # result. load_game()
def load_game(): print('\n' + "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. " + '\n' + "3. Currency Roulette - try and guess the value of random amount of USD in ILS." + "\n") chosen_game = int(input("Enter the number of the game here: ")) while chosen_game > 3 or chosen_game < 1: print("Invalid game number") chosen_game = int(input("Choose game number between 1 to 3: ")) difficulty = int(input("Choose game difficulty between 1 to 5: ")) while difficulty > 5 or difficulty < 1: print("invalid difficulty") difficulty = int(input("Choose game difficulty between 1 to 5: ")) try: if chosen_game == 1: win = play_memory_game(difficulty) if win == True: add_score(difficulty) else: print("You did'nt win points on this round ") elif chosen_game == 2: win = play_guess_game(difficulty) if win == True: add_score(difficulty) else: print("You did'nt win points on this round ") elif chosen_game == 3: win = play_currency_game(difficulty) if win == True: add_score(difficulty) else: print("You did'nt win points on this round ") except BaseException as e: print('Error: Game not found') print(e.args)
gamer_name = get_gamer_name() host_ip = get_host_ip() while True: which_game2play = load_game(num_of_games) num_of_games_list = create_list(num_of_games) if (which_game2play in num_of_games_list): if (which_game2play in (1,2,3)): get_difficulty = get_game_difficulty(games_name[which_game2play - 1], num_of_difficulties) if (which_game2play == 1): game_score = play_memory_game(get_difficulty) elif (which_game2play == 2): game_score,computer_num = guess_num(get_difficulty) elif (which_game2play == 3): game_score = play_currency_roulette(get_difficulty) elif (which_game2play == 4): play_seven_boom() else: print(games_name[which_game2play-1]) else: print("No Game Found") if (which_game2play != 4):
def load_game(): global player_name while True: game_to_play_number_input = input("\nPlease 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 choose like the computer"\ "\n3. Exit" "\nEnter here: ") game_to_play_number = game_to_play_number_input.strip() if game_to_play_number.isdigit(): game_to_play_number = int(game_to_play_number) if game_to_play_number == FIRST_GAME_NUM \ or game_to_play_number == SECOND_GAME_NUM\ or game_to_play_number == THIRD_GAME_NUM: break else: print('\n' + ERROR_MESSAGE) else: print('\n' + ERROR_MESSAGE) if game_to_play_number == THIRD_GAME_NUM: return difficulty_range = range(HIGHEST_DIFFICULTY) while True: game_difficulty_input = input( "\nPlease choose game difficulty from 1 to 5: ") game_difficulty = game_difficulty_input.strip() if game_difficulty.isdigit(): game_difficulty = int(game_difficulty) if (game_difficulty - 1) in difficulty_range: break else: print('\n' + ERROR_MESSAGE) else: print('\n' + ERROR_MESSAGE) if game_to_play_number == FIRST_GAME_NUM: is_player_win = play_memory_game(game_difficulty) while is_player_win == None: while True: game_difficulty_input = input( "\nPlease choose game difficulty from 1 to 5: ") game_difficulty = game_difficulty_input.strip() if game_difficulty.isdigit(): game_difficulty = int(game_difficulty) if (game_difficulty - 1) in difficulty_range: break else: print('\n' + ERROR_MESSAGE) else: print('\n' + ERROR_MESSAGE) is_player_win = play_memory_game(game_difficulty) if is_player_win == False: print('\n' + player_name + " - sorry, you lost the current game") load_game() else: print('\n' + player_name + " - congratulations - you win the current game with " + str(game_difficulty) + " points!!!") add_score(game_difficulty) load_game() elif game_to_play_number == SECOND_GAME_NUM: is_player_win = play_guess_game(game_difficulty) if is_player_win == False: print('\n' + player_name + " - you lost the current game") load_game() else: print('\n' + player_name + " - congratulations - you win the current game with " + str(game_difficulty) + " points!!!") add_score(game_difficulty) load_game() else: None