def homegame(): msc_intro() print("""\ _ _ _ _ _ ___ ( ) ( ) _ _ (_ ) (_ ) ( ) ( _`\ _ _ | |/'/'(_) _ __ (_) | | | | |/ ___ | |_) )(_) ____ ____ __ _ __ (_) _ _ | , < | |( '__)| | | | | | /',__) | ,__/'| |(_ ,)(_ ,) /'__`\( '__)| | /'_` ) | |\`\ | || | | | | | | | \__, \ | | | | /'/_ /'/_ ( ___/| | | |( (_| | (_) (_)(_)(_) (_)(___)(___) (____/ (_) (_)(____)(____)`\____)(_) (_)`\__,_) \`"-. ____ _ _ ____ ) _`-. / ___|| |_ __ _ _ __| |_ / ___| __ _ _ __ ___ ___ , : `. ; \___ \| __/ _` | '__| __| | | _ / _` | '_ ` _ \ / _ \ : _ ' ; ___) | || (_| | | | |_ | |_| | (_| | | | | | | __/ ; *` _. `--._ |____/ \__\__,_|_| \__| \____|\__,_|_| |_| |_|\___| `-.-' `-. ______ _____ _ __ | ` `. / / _ \ _ __ ___ ___ ___ | ____|_ __ | |_ ___ _ _\ \ :. . . | || |_) | '__/ _ \/ __/ __| | _| | '_ \| __/ _ \ '__| | | \ . : .-' . | || __/| | | __/\__ \__ \ | |___| | | | || __/ | | | : )-.; ; / : | ||_| |_| \___||___/___/ |_____|_| |_|\__\___|_| | | : ; | : : ;-. \_\ /_/ ; / : |`-: _ `- ) ,-' / ,-' ; .-`- .' `--' `--' `---' `---' COPYRIGHT © 1956 Papa Kirill All rights reserved """) if input() == None: homegame() else: utilities.clear_console()
def use_item(item, clear_console=True): if clear_console: utilities.clear_console() if not variables.backpack[item]["drink"] and not variables.backpack[item][ "eat"] and not variables.backpack[item]["blind"]: print(f'\n{variables.backpack[item]["message"]}') utilities.continue_or_exit() elif variables.backpack[item]["drink"] and not variables.backpack[item][ "eat"] and not variables.backpack[item]["blind"]: print( f'\nTon avatar gagne {variables.backpack[item]["value_hydration"]} point(s) d hydratation.' ) if variables.backpack[item]["value_hydration"] != 0: print("\nLa chance ! ") print( f'Avec {variables.backpack[item]["name"]}, tu gagnes aussi {variables.backpack[item]["value_satiety"]} point(s) de satiété.' ) utilities.continue_or_exit() elif not variables.backpack[item]["drink"] and variables.backpack[item][ "eat"] and not variables.backpack[item]["blind"]: print( f'\nTon avatar gagne {variables.backpack[item]["value_satiety"]} point(s) de satiété.' ) if variables.backpack[item]["value_satiety"] != 0: print("\nLa chance ! ") print( f'Avec {variables.backpack[item]["name"]}, tu gagnes aussi {variables.backpack[item]["value_hydration"]} point(s) d hydratation.' ) utilities.continue_or_exit() elif variables.backpack[item]["drink"] and variables.backpack[item][ "eat"] and not variables.backpack[item]["blind"]: print("Il y a à boire et à manger avec ça !") print( f'\nTon avatar gagne {variables.backpack[item]["value_hydration"]} point(s) d hydratation et {variables.backpack[item]["value_satiety"]} point(s) de satiété.' ) utilities.continue_or_exit() elif variables.backpack[item]["blind"]: if clear_console: utilities.clear_console() print( "\nQue se passe-t-il ????\n Tout s'assombrit... \nOMG ! Tu deviens aveugle..." ) utilities.show_image("eyes") time.sleep(10) # update counters, but not over the max value variables.counters["hydration"]["value"] += variables.backpack[item][ "value_hydration"] if variables.counters["hydration"]["value"] > variables.counters[ "hydration"]["value_max"]: variables.counters["hydration"]["value"] = variables.counters[ "hydration"]["value_max"] variables.counters["satiety"]["value"] += variables.backpack[item][ "value_satiety"] if variables.counters["satiety"]["value"] > variables.counters["satiety"][ "value_max"]: variables.counters["satiety"]["value"] = variables.counters["satiety"][ "value_max"] if variables.backpack[item]["drop_on_floor"]: # update backpack del variables.backpack[item]
def show_rules(clear_console=True): """ shows the rules. """ while variables.game_in_progress: if clear_console: utilities.clear_console() print(" Les règles du jeu de") print(" Python Mysterious Island !") print(" - - - - - - - - - - - - - ") print() print("Objectifs ::") print("1- Récupérer les 3 clés situées dans les 3 lieux mystérieux.") print( "2- Te rendre au 4e lieu mystérieux dans la montagne avec les 3 clés." ) print() print("Règles particulières :") print( " - lorsque les objectifs ci-dessus sont remplis, la partie est gagnée" ) print( " - si ton avatar perd tous ses points de soif, la partie est perdue" ) print( " - si ton avatar perd tous ses points de faim, la partie est perdue" ) print( " - si ton avatar perd tous ses points de vie, la partie est perdue" ) print() print("Instructions comprises par l'avatar :") print(" - le déplacer en choisissant sa direction :") print(" - vers le (H)aut de n cases (par exemple H2)") print(" - vers le (B)as de n cases (par exemple B6)") print(" - vers la (D)roite de n cases (par exemple D5)") print(" - vers la (G)auche de n cases (par exemple G1)") print(" - (P)rendre un objet et le mettre dans le sac à dos") print(" - (U)tiliser un object") print(" - (A)bandonner un object au sol") print(" - s'h(Y)drater pour augmenter ses points d'hydratation") print(" - (M)anger pour augmenter ses points de satiété") print(" - se (R)eposer pour récupérer des points de vie") print(" - (S)auvegarder la partie") print(" - (T)élécharger la partie") print(" - (Q)uitter le jeu (et échouer)") print("Une seule action (lettre) à la fois.") print() utilities.continue_or_exit() return # A vérifier si toujours utile, car normalement la boucle while doit s'arrêter !!
def quick_time(): # Function to fire at the enemy for i in range(5, 0, -1): utilities.clear_console() print(" ____ ____ _ _ _ ") print(" | _ \ | _ \ | | | | | | ") print(" | |_) | ___ ___ ___ | |_) | __ _| |_| |_| | ___ ") print(" | _ < / _ \/ __/ __| | _ < / _` | __| __| |/ _ \\") print(" | |_) | (_) \__ \__ \ | |_) | (_| | |_| |_| | __/") print(" |____/ \___/|___/___/ |____/ \__,_|\__|\__|_|\___|\n") print( "{}: 'So, you found me detective. Well now there's no escape... for you!'" .format(enemy["name"])) print("He draws his gun.") print("You: 'You son of a bitch!'") print("You draw your gun.") print("\nPress ENTER to fire at {}.\n".format(enemy["name"])) print("You:\t HP={}\tRounds={}/6".format(health_points, rounds)) print("{}: HP={}\tRounds={}/6\n".format(enemy["name"], enemy["hp"], enemy["rounds"])) print(i) time.sleep(1) utilities.clear_console() print(" ____ ____ _ _ _ ") print(" | _ \ | _ \ | | | | | | ") print(" | |_) | ___ ___ ___ | |_) | __ _| |_| |_| | ___ ") print(" | _ < / _ \/ __/ __| | _ < / _` | __| __| |/ _ \\") print(" | |_) | (_) \__ \__ \ | |_) | (_| | |_| |_| | __/") print(" |____/ \___/|___/___/ |____/ \__,_|\__|\__|_|\___|\n") print( "{}: 'So, you found me detective. Well now there's no escape... for you!'" .format(enemy["name"])) print("He draws his gun.") print("You: 'You son of a bitch!'") print("You draw your gun.") print("\nPress ENTER to fire at {}.\n".format(enemy["name"])) print("You:\t HP={}\tRounds={}/6".format(health_points, rounds)) print("{}: HP={}\tRounds={}/6\n".format(enemy["name"], enemy["hp"], enemy["rounds"])) print("PRESS ENTER") start = time.time() input() end = time.time() difference = end - start if difference > 1: accuracy = 1 else: accuracy = difference return calc_damage(accuracy) return
def get_name_and_symbol(clear_console=True): """ gets the name of the player asks which symbol she/he wants for her/his avatar """ while variables.game_in_progress: print( "Mais avant de commencer, tu dois répondre aux 2 questions suivantes :" ) player_name = input("Quel est ton nom ? ") variables.players_fizzbuzz["avatar"]["name_monkey"] = player_name variables.player_name = player_name print() print( f'Bienvenue {(variables.players_fizzbuzz["avatar"]["name_monkey"]).capitalize()} !' ) print() print("Quel symbole souhaites-tu pour ton avatar ?") for key in variables.avatar_symbol.keys(): print( f'- {variables.avatar_symbol[key]["name"]} :: {variables.avatar_symbol[key]["color_start"]}{variables.avatar_symbol[key]["symbol"]}{variables.avatar_symbol[key]["color_end"]}' ) variables.letter_avatar_symbol = input( f"Choisis maintenant entre {variables.possibles_avatar_symbol} : " ).upper() print() if clear_console: utilities.clear_console() print() if variables.letter_avatar_symbol == "L": variables.avatar_symbol_current = variables.avatar_symbol["L"][ "color_start"] + variables.avatar_symbol["L"][ "symbol"] + variables.avatar_symbol["L"][ "color_end"] #### trouver la solution ############### print(variables.avatar_symbol["L"]["message"]) elif variables.letter_avatar_symbol == "K": variables.avatar_symbol_current = variables.avatar_symbol["K"][ "color_start"] + variables.avatar_symbol["K"][ "symbol"] + variables.avatar_symbol["K"]["color_end"] print(variables.avatar_symbol["K"]["message"]) elif variables.letter_avatar_symbol != "L" and variables.letter_avatar_symbol != "K": variables.letter_avatar_symbol = "N" variables.avatar_symbol_current = variables.avatar_symbol["N"][ "color_start"] + variables.avatar_symbol["N"][ "symbol"] + variables.avatar_symbol["N"]["color_end"] print(variables.avatar_symbol["N"]["message"]) return return variables.avatar_symbol_current
def show_new_map(clear_console=True): """ draws the map with the current placements of everything """ if clear_console: utilities.clear_console() while variables.game_in_progress: utilities.load_map_from_file("map1") for Y in range(len(variables.map1)): for X in range(len(variables.map1[Y])): if variables.map1[Y][ X] in variables.possibles_avatar_symbol and variables.map1[ Y][X] != " ": # if above is true, avatar is in this place, so draw it print(f'{variables.avatar_symbol_current}', end="") elif variables.map1[Y][X] in variables.place.keys(): print( f'{variables.place[variables.map1[Y][X]]["color_start"]}{variables.place[variables.map1[Y][X]]["image"]}{variables.place[variables.map1[Y][X]]["color_end"]}', end="") elif variables.map1[Y][ X] in variables.possibles_item_symbol and variables.map1[ Y][X] != " " and variables.map1[Y][X] != "r": # if above is true, item is in this place, so draw it print(variables.symbol_items, end="") current_item_found = variables.map1[Y][X] elif variables.map1[Y][ X] in variables.possibles_item_symbol and variables.map1[ Y][X] != " " and variables.map1[Y][X] == "r": # if above is true, item is in this place, so draw it print(variables.items_available["r"]["symbol_items"], end="") current_item_found = variables.map1[Y][X] else: # if not, draw the item of the map print( f'{variables.map_elements[variables.map1[Y][X]]["color_start"]}{variables.map_elements[variables.map1[Y][X]]["image"]}{variables.map_elements[variables.map1[Y][X]]["color_end"]}', end="") print() return
def play_item(item, clear_console=True): """ choose what to do with the item """ if clear_console: utilities.clear_console() print( f'Tu viens de trouver {variables.items_available[item]["name"]}.\n Tu peux :' ) print( " - \u001b[1m(P)\u001b[0mrendre l'objet et le mettre dans ton sac à dos" ) print(" - \u001b[1m(U)\u001b[0mtiliser l'object aussitôt") print(" - \u001b[1m(A)\u001b[0mbandonner l'object au sol") action_item = input("\nQue veux-tu faire ? ").upper() if action_item == "P": # put the item in the backpack variables.backpack[item] = (variables.items_available[item]) # modify counter variables.counters["number_actions"]["value"] += 1 # clear console if clear_console: utilities.clear_console() # print a little message print( f'\nVoilà {variables.items_available[item]["name"]} dans ton sac à dos !\n{variables.items_available[item]["message"]}\nRetour à la carte...' ) time.sleep(variables.message_speed) elif action_item == "U": if clear_console: utilities.clear_console() # print a little message print("\nBonne idée !\n") # put item in the back pack to use it (not good, has to be modified) variables.backpack[item] = (variables.items_available[item]) # use item use_item(item) # modify counter variables.counters["number_actions"]["value"] += 1 pass elif action_item == "A": # do nothing print("Tu as décidé de le laisser là.\nRetour à la carte...") time.sleep(variables.message_speed)
def caesar_code_play(clear_console=True): """ plays the code caesar """ if clear_console: utilities.clear_console() print(" Défi 2 :") print(" Le code César") print(" - - - - - - - ") print() # the player can't play if he has already the sliver key if "s" in variables.backpack.keys(): print("Tu as déjà cette clé.") time.sleep(variables.message_speed) return # codes the sentence # and shows it print("Voici le message incompréhensible figurant sur l'arche : ") print( get_coded_texte(variables.letter_code_random, variables.original_message)) print(variables.letter_code_random) print() print( "Tu peux essayer de changer ce message en appuyant sur une des lettres figurant sur les colonnes de l'arche." ) print() letter_code_player = (input( "--> Tape une lettre pour essayer de faire apparaître le message en clair : " )).upper() print("\nLe message sur l'arche se modifie...") print("...") print( f"En appuyant sur la lettre {letter_code_player}, tu as fait apparaître le message suivant :" ) while letter_code_player != variables.letter_code_random: print(get_coded_texte(letter_code_player, variables.original_message)) print("\nCa ne veut toujours rien dire !\n") test_other_letter = ( input("Veux-tu essayer avec une autre lettre ? (O)ui ou (N)on : ") ).upper() if test_other_letter == "O": print() letter_code_player = (input( "--> Tape une lettre pour essayer de faire apparaître le message en clair : " )).upper() print() print("Le message sur l'arche se modifie...") print("...") print( f"En appuyant sur la lettre {letter_code_player}, tu as fait apparaître le message suivant :" ) if letter_code_player == variables.letter_code_random: print( decrypt_texte( letter_code_player, get_coded_texte(letter_code_player, variables.original_message))) print() count_letter = variables.number_code + 1 print( f"Bravo ! Tu sais maintenant que la clé du code César est la lettre {variables.letter_code_random}.\n Il faut décaler chaque lettre de {count_letter} lettres dans l'alphabet." ) print() test_name = (input( "Veux-tu tenter maintenant d'écrire ton prénom en suivant le code césar ? (O)ui ou (N)on : " )).upper() if test_name == "O": test_coded_name() else: utilities.continue_or_exit() game.show_dashboard() return elif letter_code_player != variables.letter_code_random: get_coded_texte(letter_code_player, variables.original_message) print() elif test_other_letter == "N": test_name = (input( "Veux-tu tenter maintenant d'écrire ton prénom en suivant le code césar ? (O)ui ou (N)on : " )).upper() if test_name == "O": test_coded_name() else: utilities.continue_or_exit() game.show_dashboard() return print( decrypt_texte( letter_code_player, get_coded_texte(letter_code_player, variables.original_message))) print() count_letter = variables.number_code + 1 print( f"Bravo ! Tu sais maintenant que la clé du code César est la lettre {variables.letter_code_random}.\n Il faut décaler chaque lettre de {count_letter} lettres dans l'alphabet." ) print() test_name = (input( "Veux-tu tenter maintenant d'écrire ton prénom en suivant le code césar ? (O)ui ou (N)on : " )).upper() if test_name == "O": test_coded_name() else: utilities.continue_or_exit() game.show_dashboard() return utilities.continue_or_exit() game.show_dashboard() print() return
def execute_avatar_action(current_action, action_occurences=1, clear_console=True): """ executes action """ new_avatar_x = variables.avatar_position["x"] new_avatar_y = variables.avatar_position["y"] # prepare current_action while variables.game_in_progress: # avatar moves up if current_action == "H": for movement in range(0, action_occurences): if new_avatar_y + movement > 0: # move avatar new_avatar_y -= 1 # update counters variables.counters["number_movements"]["value"] += 1 variables.counters["life"]["value"] += variables.counters[ "life"]["movement"] variables.counters["hydration"][ "value"] += variables.counters["hydration"]["movement"] variables.counters["satiety"][ "value"] += variables.counters["satiety"]["movement"] # game continues variables.game_in_progress = variables.actions["H"][ "game_in_progress"] else: # if action go to high, print message print(variables.actions["H"]["impossible"]) new_avatar_y = 0 # change avatar position x and y variables.avatar_position["x"] = new_avatar_x variables.avatar_position["y"] = new_avatar_y # clear console if clear_console: utilities.clear_console() # show message print(variables.actions["H"]["message"]) # keep the message visible for a while time.sleep(variables.message_speed) return # avatar moves down elif current_action == "B": for movement in range(action_occurences): if new_avatar_y + movement < 30: # move avatar new_avatar_y += 1 # update counters variables.counters["number_movements"]["value"] += 1 variables.counters["life"]["value"] += variables.counters[ "life"]["movement"] variables.counters["hydration"][ "value"] += variables.counters["hydration"]["movement"] variables.counters["satiety"][ "value"] += variables.counters["satiety"]["movement"] # game continues variables.game_in_progress = variables.actions["B"][ "game_in_progress"] else: # if action go to down, print message print(variables.actions["B"]["impossible"]) new_avatar_y = 30 # change avatar position x and y variables.avatar_position["x"] = new_avatar_x variables.avatar_position["y"] = new_avatar_y # clear console if clear_console: utilities.clear_console() # show message print(variables.actions["B"]["message"]) # keep the message visible for a while time.sleep(variables.message_speed) return # avatar moves to the left elif current_action == "G": for movement in range(action_occurences): if new_avatar_x + movement > 0: # move avatar new_avatar_x -= 1 # update counters variables.counters["number_movements"]["value"] += 1 variables.counters["life"]["value"] += variables.counters[ "life"]["movement"] variables.counters["hydration"][ "value"] += variables.counters["hydration"]["movement"] variables.counters["satiety"][ "value"] += variables.counters["satiety"]["movement"] # game continues variables.game_in_progress = variables.actions["G"][ "game_in_progress"] elif new_avatar_x + movement < 0: # if action go to right, print message print(variables.actions["G"]["impossible"]) new_avatar_x = 0 # change avatar position x and y variables.avatar_position["x"] = new_avatar_x variables.avatar_position["y"] = new_avatar_y # clear console if clear_console: utilities.clear_console() # show message print(variables.actions["G"]["message"]) # keep the message visible for a while time.sleep(variables.message_speed) return # avatar moves to the right elif current_action == "D": for movement in range(action_occurences): if new_avatar_x + movement < 80: # move avatar new_avatar_x += 1 # update counters variables.counters["number_movements"]["value"] += 1 variables.counters["life"]["value"] += variables.counters[ "life"]["movement"] variables.counters["hydration"][ "value"] += variables.counters["hydration"]["movement"] variables.counters["satiety"][ "value"] += variables.counters["satiety"]["movement"] # game continues variables.game_in_progress = variables.actions["D"][ "game_in_progress"] elif new_avatar_x + movement > 80: # if action go to right, print message print(variables.actions["D"]["impossible"]) new_avatar_x = 80 # change avatar position x and y variables.avatar_position["x"] = new_avatar_x variables.avatar_position["y"] = new_avatar_y # clear console if clear_console: utilities.clear_console() # show message print(variables.actions["D"]["message"]) # keep the message visible for a while time.sleep(variables.message_speed) return elif current_action == "R": if clear_console: utilities.clear_console() # get the number of hour the avatar havs to sleep print() print("Tu as décidé de dormir.") print( f'Ton avatar gagne {variables.counters["life"]["dormir"]} point de vie par heure dormie.' ) nb_hour_sleep = int(input("Combien d'heure(s) ? ")) # modify the counter of "life", "hydratation" and "satiety" variables.counters["life"][ "value"] += nb_hour_sleep * variables.counters["life"]["dormir"] variables.counters["hydration"][ "value"] += nb_hour_sleep * variables.counters["hydration"][ "dormir"] variables.counters["satiety"][ "value"] += nb_hour_sleep * variables.counters["satiety"][ "dormir"] # check if the life value doesn't go over the max value, if yes, keep the max value no more if variables.counters["life"]["value"] > variables.counters[ "life"]["value_max"]: variables.counters["life"]["value"] = variables.counters[ "life"]["value_max"] # clear console if clear_console: utilities.clear_console() # print a little message print(variables.actions["R"]["message"]) # for hour in range(nb_hour_sleep+1) : # nb_hour_sleep_left = nb_hour_sleep - hour # if hour == 0 : # continue # elif nb_hour_sleep == 1 and hour >= 1 : # print(f"Ton avatar a dormi 1 heure.\nIl est temps de se réveiller !!") # time.sleep(variables.message_speed) # elif nb_hour_sleep_left == 1 and hour >= 1 : # print(f"Ton avatar dort depuis {hour} heure.\nIl est temps de se réveiller !!") # time.sleep(variables.message_speed) # elif hour == nb_hour_sleep+1: # print(f"Ton avatar a dormi {hour} heure(s).\nEncore {nb_hour_sleep_left}...") # else: # print(f"Ton avatar dort depuis {hour} heures.\nEncore {nb_hour_sleep_left}...") # time.sleep(variables.message_speed) time.sleep(variables.message_speed * nb_hour_sleep) # game still in progress variables.game_in_progress = variables.actions["R"][ "game_in_progress"] # update counters variables.counters["number_actions"]["value"] += 1 return elif current_action == "O": # clear console if clear_console: utilities.clear_console() # print a little message print(variables.actions["O"]["message"]) time.sleep(variables.message_speed) # open the backpack open_backpack() # game still in progress variables.game_in_progress = variables.actions["O"][ "game_in_progress"] # update counters variables.counters["number_actions"]["value"] += 1 return elif current_action == "P": print(variables.actions["P"]["message"]) variables.game_in_progress = variables.actions["P"][ "game_in_progress"] # update counters variables.counters["number_actions"]["value"] += 1 return elif current_action == "U": print(variables.actions["U"]["message"]) variables.game_in_progress = variables.actions["U"][ "game_in_progress"] # update counters variables.counters["number_actions"]["value"] += 1 return elif current_action == "A": print(variables.actions["A"]["message"]) variables.game_in_progress = variables.actions["A"][ "game_in_progress"] return elif current_action == "L": if clear_console: utilities.clear_console() print("*** Ladies Mode ***") print("Les 3 clés apparaissent dans ton sac.") print("Te voilà téléportée au pied de la mystérieuse porte...") variables.backpack["s"] = (variables.game_keys["s"]) variables.backpack["g"] = (variables.game_keys["g"]) variables.backpack["b"] = (variables.game_keys["b"]) variables.avatar_position["x"] = 32 variables.avatar_position["y"] = 6 utilities.continue_or_exit() return elif current_action == "Y": print(variables.actions["Y"]["message"]) variables.game_in_progress = variables.actions["Y"][ "game_in_progress"] # update counters variables.counters["number_actions"]["value"] += 1 return elif current_action == "M": print(variables.actions["M"]["message"]) variables.game_in_progress = variables.actions["M"][ "game_in_progress"] # update counters variables.counters["number_actions"]["value"] += 1 return elif current_action == "Q": print(variables.actions["Q"]["message"]) variables.game_in_progress = variables.actions["Q"][ "game_in_progress"] # update counters # variables.counters["number_actions"]["value"] += 1 return elif current_action == "C": print(variables.actions["C"]["message"]) variables.game_in_progress = variables.actions["C"][ "game_in_progress"] # update counters # variables.counters["number_actions"]["value"] += 1 elif current_action == "S": print(variables.actions["S"]["message"]) variables.game_in_progress = variables.actions["S"][ "game_in_progress"] # update counters # variables.counters["number_actions"]["value"] += 1 return elif current_action == "T": print(variables.actions["T"]["message"]) variables.game_in_progress = variables.actions["T"][ "game_in_progress"] # update counters # variables.counters["number_actions"]["value"] += 1 return # if game is already ended, go out of the loop # return print("Game_in_progress = False !!!!!!") return # A vérifier si toujours utile, car normalement la boucle while doit s'arrêter !!
def show_dashboard(clear_console=True): """ draws dashbord with map, instructions and live counter """ while variables.game_in_progress: if clear_console: utilities.clear_console() # show the map show_new_map() # shows the counters : eat, drink, live, items in the bag, ... utilities.show_counter() # if one of the counter is 0, game is over if variables.counters["life"]["value"] < variables.counters["life"][ "value_min"]: if clear_console: utilities.clear_console() print(variables.counters["life"]["message_mort"]) utilities.show_image("skull") return if variables.counters["hydration"]["value"] < variables.counters[ "hydration"]["value_min"]: if clear_console: utilities.clear_console() print(variables.counters["hydration"]["message_mort"]) utilities.show_image("skull") return if variables.counters["satiety"]["value"] < variables.counters[ "satiety"]["value_min"]: if clear_console: utilities.clear_console() print(variables.counters["hydration"]["message_mort"]) utilities.show_image("skull") return # shows intructions of the avatar's action utilities.show_instructions() # asks player which action she/he wants to play (letter_action, number_action) = get_avatar_action() # if valid action, execute action execute_avatar_action(letter_action, number_action) # if avatar on the game "1", play the game 1 if variables.avatar_position["y"] == variables.place["1"][ "ln_y"] and variables.avatar_position["x"] == variables.place[ "1"]["col_x"]: mysterious_number_file.mysterious_number_play() # if avatar on the game "2", play the game 2 if variables.avatar_position["y"] == variables.place["2"][ "ln_y"] and variables.avatar_position["x"] == variables.place[ "2"]["col_x"]: caesar_code_file.caesar_code_play() # if avatar on the game "3", play the game 3 if variables.avatar_position["y"] == variables.place["3"][ "ln_y"] and variables.avatar_position["x"] == variables.place[ "3"]["col_x"]: multi_fizzbuzz_file.multi_fizzbuzz_play() # if avatar on the gate and if he has the 3 keys, the player win if variables.avatar_position["y"] == variables.place["4"]["ln_y"]: if variables.avatar_position["x"] == variables.place["4"]["col_x"]: if "g" in variables.backpack.keys( ) and "s" in variables.backpack.keys( ) and "b" in variables.backpack.keys(): if clear_console: utilities.clear_console() print(f'{variables.player_name} a gagné !') utilities.show_image("fist") time.sleep(20) else: print("Tu as cru quoi ???") time.sleep(20) # check if there is an item where the avatar is for keys in variables.items_available: for number in range(variables.items_available[keys]["number"]): if (variables.avatar_position["y"] == variables.items_available[keys]["ln_y"][number] and variables.avatar_position["x"] == variables.items_available[keys]["col_x"][number]): # if above is true, there is an item here, ask to the player what to do play_item(keys)
def show_title_and_story(clear_console=True): """ shows the title and the story at the beginning. """ if clear_console: utilities.clear_console() print(" Bienvenue à") print(" Python Mysterious Island !") print(" - - - - - - - - - - - - - \n") print( "Arriveras-tu à survivre pour découvrir le grand mystère caché au centre de l'ïle ?" ) print() print("Une seule manière de le savoir : L'ACTION !") print() print("Tu devras te déplacer pour rejoindre l'emplacement des 3 défis. " ) ##### Mettre les symbols print("Pour chaque défi relevé, tu gagneras une clé." ) ##### Mettre les symbols print( "À l'aide de ces 3 clés, tu pourras ouvrir la porte secrète cachée dans la montagne." ) ##### Mettre le symbol print() print("Mais attention...") print("Sur l'île, il fait chaud... ") print("Tu auras faim... ") print("Et l'épuisement ne sera jamais très loin...") print( "Donc, prends soin de tes 3 signes vitaux !") ##### Mettre les symbols print() print( "Dans cette aventure, tu as une malette avec un ordinateur et un système de recharge photovoltaïque." ) print("Surprenant d'avoir ce type de matériel et du réseau ici, non ?") print("Tu découvriras bien assez tôt à quoi il te servira.") print() print("Heureusement, tu n'as pas que cette malette.") print() print("Tu as aussi un sac à dos.") ##### Mettre dessin ascii print("À l'intérieur, un petit couteau multifonctions de bonne facture.") print("Indispensable, pour l'aventurier.e que tu es.") print() print("Et une bouteille vide en verre.") ##### Mettre le symbol print("Tu réfléchis déjà où tu vas pouvoir aller la remplir ?") print("Je te donne mon premier conseil :") print("...attention à l'eau salée qui te rendra malade.") print() print("C'est bien léger pour survivre sur cette île inconnue...") print( "À toi de remplir ton sac à dos avec ce que tu trouveras sur ton chemin." ) print() print("Seulement, ce n'est pas le sac de Mary Poppins.") print("Et tu ne pourras y mettre que 10 objets.") print("Mon deuxième conseil sera le suivant :") print("Méfies-toi de ce que tu mettras dans ton sac à dos...") print() print("Il est encore temps de quitter le jeu si tu as trop peur...") utilities.continue_or_exit()
def multi_fizzbuzz_play(clear_console=True): """ plays the multi_fizzbuzz """ if clear_console: utilities.clear_console() # the player can't play if he has already the gold key if "g" in variables.backpack.keys(): print("Tu as déjà cette clé.") time.sleep(variables.message_speed) return print(" Défi 3 :") print(" Le multi FizzBuzz") print(" - - - - - - - - - ") print() keys_players = variables.players_fizzbuzz.keys() list_players = list(keys_players) nb_players = len(list_players) nb_players_left = nb_players index = 1 while nb_players_left > 2: for player in list_players: print() good_answer = get_good_answer(index) answer_player = get_answer_player(player, good_answer, index) if answer_player != good_answer and player != "avatar": print( f'{(variables.players_fizzbuzz[player]["name_monkey"]).capitalize()} a perdu !' ) list_players.remove(player) index = 1 nb_players_left -= 1 print(f'Il y a encore {len(list_players)} joueurs.') time.sleep(variables.fizz_speed) elif answer_player != good_answer and player == "avatar": print( "-->\u001b[1mTu as perdu !\u001b[0m\nRetente ta chance plus tard." ) utilities.continue_or_exit() game.show_dashboard() print() return elif answer_player == good_answer and player == "avatar": print("\u001b[1mBien joué !\u001b[0m") index += 1 time.sleep(2) elif answer_player == good_answer and player != "avatar": index += 1 time.sleep(2) while nb_players_left == 2: for player in list_players: print() good_answer = get_good_answer(index) answer_player = get_answer_player(player, good_answer, index) if answer_player != good_answer and player != "avatar": print( f'{(variables.players_fizzbuzz[player]["name_monkey"]).capitalize()} a perdu !' ) time.sleep(variables.fizz_speed) list_players.remove(player) nb_players_left -= 1 elif answer_player != good_answer and player == "avatar": print( "-->\u001b[1mTu as perdu !\u001b[0m\nRetente ta chance. Tu as été jusqu'en finale !" ) utilities.continue_or_exit() game.show_dashboard() print() return elif answer_player == good_answer and player == "avatar": print("\u001b[1mBien joué !\u001b[0m") index += 1 time.sleep(2) elif answer_player == good_answer and player != "avatar": index += 1 time.sleep(2) if nb_players_left == 1: for player in list_players: winner = player print( f'\n{(variables.players_fizzbuzz[winner]["name_monkey"]).capitalize()}, tu as gagné !' ) print("-->\u001b[1mTu obtiens la clé d'or !\u001b[0m\n") # put the key in the backpack variables.backpack["g"] = (variables.game_keys["g"]) # continue or exit utilities.continue_or_exit() game.show_dashboard() print() return
def combat(r, hp, ps): global rounds rounds = r global health_points health_points = hp player_steps = ps if player_steps > 50: enemy["accuracy"] -= 0.50 else: enemy["accuracy"] -= player_steps / 100 enemy["rounds"] += int(player_steps / 10) if enemy["rounds"] > 6: enemy["rounds"] = 6 output = "" while health_points > 0 and enemy["hp"] > 0 and rounds > 0 and enemy[ "rounds"] > 0: utilities.clear_console() print(" ____ ____ _ _ _ ") print(" | _ \ | _ \ | | | | | | ") print(" | |_) | ___ ___ ___ | |_) | __ _| |_| |_| | ___ ") print(" | _ < / _ \/ __/ __| | _ < / _` | __| __| |/ _ \\") print(" | |_) | (_) \__ \__ \ | |_) | (_| | |_| |_| | __/") print(" |____/ \___/|___/___/ |____/ \__,_|\__|\__|_|\___|\n") print( "{}: 'So, you found me detective. Well now there's no escape... for you!'" .format(enemy["name"])) print("He draws his gun.") print("You: 'You son of a bitch!'") print("You draw your gun.") print("\nPress ENTER to fire at {}.\n".format(enemy["name"])) print("You:\t HP={}\tRounds={}/6".format(health_points, rounds)) print("{}: HP={}\tRounds={}/6\n".format(enemy["name"], enemy["hp"], enemy["rounds"])) if output != "": print(output) input() output = quick_time() utilities.clear_console() print(" _____ ____ ") print(" / ____| / __ \ ") print(" | | __ __ _ _ __ ___ ___ | | | |_ _____ _ __ ") print(" | | |_ |/ _` | '_ ` _ \ / _ \ | | | \ \ / / _ \ '__|") print(" | |__| | (_| | | | | | | __/ | |__| |\ V / __/ | ") print(" \_____|\__,_|_| |_| |_|\___| \____/ \_/ \___|_| \n") print( "{}: 'So, you found me detective. Well now there's no escape... for you!'" .format(enemy["name"])) print("He draws his gun.") print("You: 'You son of a bitch!'") print("You draw your gun.") print("\nPress ENTER to fire at {}.\n".format(enemy["name"])) print("You:\t HP={}\tRounds={}/6".format(health_points, rounds)) print("{}: HP={}\tRounds={}/6\n".format(enemy["name"], enemy["hp"], enemy["rounds"])) print(output) if health_points <= 0 and enemy["hp"] <= 0: return """ You have neutralized each other and while you are both on the floor breathing your last breaths Octavio Ricca tells you that he is not the killer. In those last moments, you remember about the dough you picked up at the beginning of the game. If you've inspected the dough you would know that the hand mark came from someone with very large hands. This hand mark didn't match Papa Kirill's or any of the apprentices' hands in the restaurant. You look at Octavio's hands, they are average size. "Then why?..." you say before dying. You have completed the game but failed. Try again.""" elif health_points <= 0: return """ Octavio has fatally shot you down. You are dying. As you die your vision gets very blurry. Your uncle appears in front of you. "You have disgraced our family by failing to avenge me!" screamed Papa Kirill. "I hope that you go to hell!" Octavio Ricca will continue to live on. During the fight, he has lost both of his arms. This injury will prevent him from causing any other disasters. Congratulations! You are a failure in the eyes of Papa Kirill.""" elif enemy["hp"] <= 0: return """ You have just killed Octavio Ricca. A rush of adrenaline still rushes through your veins. You walk towards Octavio Ricca and spit at his cadaver. You crouch and look at his corpse. Every limb is very still. His hands are still wrapped around the pistol which lay next to his face. You notice how small they are. This is very weird. When you investigated the pizzeria at the very start you had found some dough which served as evidence that the killer had big hands. It doesn't make sense. If Octavio Ricca is not the killer, then who is? Congratulations you have completed the game.""" elif rounds == 0 and enemy["rounds"] > 0: return """ You ran out of rounds. Octavio Ricca notices this and approaches, before shooting you through the head. You are dying. As you die your vision gets very blurry. Your uncle appears in front of you. "You have disgraced our family by failing to avenge me!" screamed Papa Kirill. "I hope that you go to hell!" Octavio Ricca will continue to live on. During the fight, he has lost both of his arms. This injury will prevent him from causing any other disasters. Congratulations! You are a failure in the eyes of Papa Kirill.""" else: # enemy["rounds"] == 0: return """
def combat(rounds1, health_points1, player_steps): global rounds rounds = 6 global health_points health_points = health_points1 if player_steps > 50: enemy["accuracy"] -= 0.50 else: enemy["accuracy"] -= player_steps / 100 enemy["rounds"] += int(player_steps / 10) if enemy["rounds"] > 6: enemy["rounds"] = 6 output = "" while health_points > 0 and enemy["hp"] > 0 and rounds > 0 and enemy[ "rounds"] > 0: utilities.clear_console() print(" _____ ____ _ _ _ ") print(" | __ \ | _ \ | | | | | | ") print(" | | | | __ _ _ __ ___ ___ | |_) | __ _| |_| |_| | ___ ") print(" | | | |/ _` | '_ \\ / __/ _ \\ | _ < / _` | __| __| |/ _ \\") print(" | |__| | (_| | | | | (_| __/ | |_) | (_| | |_| |_| | __/") print(" |_____/ \__,_|_| |_|\___\___| |____/ \__,_|\__|\__|_|\___|\n") print( "{}: 'So, you found me detective. Well now there's no escape... for you!'" .format(enemy["name"])) print("He starts to dance.") print("You: 'You son of a bitch!'") print("You start to dance.") print("\nPress ENTER to dance at {}.\n".format(enemy["name"])) print("You:\t HP={}\tDances={}/6".format(health_points, rounds)) print("{}: HP={}\tDances={}/6\n".format(enemy["name"], enemy["hp"], enemy["rounds"])) if output != "": print(output) input() output = quick_time() utilities.clear_console() print(" _____ ____ ") print(" / ____| / __ \ ") print(" | | __ __ _ _ __ ___ ___ | | | |_ _____ _ __ ") print(" | | |_ |/ _` | '_ ` _ \ / _ \ | | | \ \ / / _ \ '__|") print(" | |__| | (_| | | | | | | __/ | |__| |\ V / __/ | ") print(" \_____|\__,_|_| |_| |_|\___| \____/ \_/ \___|_| \n") print( "{}: 'So, you found me detective. Well now there's no escape... for you!'" .format(enemy["name"])) print("He starts to dance.") print("You: 'You son of a bitch!'") print("You start to dance.") print("\nPress ENTER to dance at {}.\n".format(enemy["name"])) print("You:\t HP={}\tDances={}/6".format(health_points, rounds)) print("{}: HP={}\tDances={}/6\n".format(enemy["name"], enemy["hp"], enemy["rounds"])) print(output) if health_points <= 0 and enemy["hp"] <= 0: return """ You have tied with each other. After the dance, you hug it out. Octavio Ricca invites you to a pub for a drink. You accept and follow him to the Green Tavern. While you are at the pub you learn from Octavio Ricca that Papa Kirill was a very bad man who would deal drugs all around Illinois. His murder was not an act of revenge or hatred but a way of protecting thousands of people. Indeed, not only did Papa Kirill deal the drugs but he also made them in his underground lab; therefore when customers weren't satisfied with the product Papa Kirill was afraid that they would talk badly about his merchandise and his solution was murder. He would change the drug to become lethal on injection. This information was very hard to digest and you ask the waitress for a bottle of vodka. You spend the rest of the night talking about your exploits around the world. A few months later you announce publicly that you are retiring from being an international detective. The media goes crazy and you get a lot of attention for many weeks. You are now running your uncle's restaurant with Octavio Ricca as your right-hand man. You are now lovers and are going to get engaged secretly. Congratulations! You have finished the game.""" elif health_points <= 0: return """You were out-danced by Octavio Ricca. After the dance, you hug it out. Octavio Ricca invites you to a pub for a drink. You accept and follow him to the Green Tavern. While you are at the pub you learn from Octavio Ricca that Papa Kirill was a very bad man who would deal drugs all around Illinois. His murder was not an act of revenge or hatred but a way of protecting thousands of people. Indeed, not only did Papa Kirill deal the drugs but he also made them in his underground lab; therefore when customers weren't satisfied with the product Papa Kirill was afraid that they would talk badly about his merchandise and his solution was murder. He would change the drug to become lethal on injection. This information was very hard to digest and you ask the waitress for a bottle of vodka. You spend the rest of the night talking about your exploits around the world. A few months later you announce publicly that you are retiring from being an international detective. The media goes crazy and you get a lot of attention for many weeks. You are now running your uncle's restaurant with Octavio Ricca as your right-hand man. You are now lovers and are going to get engaged secretly. Congratulations! You have finished the game.""" elif enemy["hp"] <= 0: return """You have out-danced Octavio Ricca. After the dance, you hug it out. Octavio Ricca invites you to a pub for a drink. You accept and follow him to the Green Tavern. While you are at the pub you learn from Octavio Ricca that Papa Kirill was a very bad man who would deal drugs all around Illinois. His murder was not an act of revenge or hatred but a way of protecting thousands of people. Indeed, not only did Papa Kirill deal the drugs but he also made them in his underground lab; therefore when customers weren't satisfied with the product Papa Kirill was afraid that they would talk badly about his merchandise and his solution was murder. He would change the drug to become lethal on injection. This information was very hard to digest and you ask the waitress for a bottle of vodka. You spend the rest of the night talking about your exploits around the world. A few months later you announce publicly that you are retiring from being an international detective. The media goes crazy and you get a lot of attention for many weeks. You are now running your uncle's restaurant with Octavio Ricca as your right-hand man. You are now lovers and are going to get engaged secretly. Congratulations! You have finished the game.""" elif rounds == 0 and enemy["rounds"] > 0: return """You ran out of mojo. Octavio Ricca notices this and approaches, before performing a killer dance move. After the dance, you hug it out. Octavio Ricca invites you to a pub for a drink. You accept and follow him to the Green Tavern. While you are at the pub you learn from Octavio Ricca that Papa Kirill was a very bad man who would deal drugs all around Illinois. His murder was not an act of revenge or hatred but a way of protecting thousands of people. Indeed, not only did Papa Kirill deal the drugs but he also made them in his underground lab; therefore when customers weren't satisfied with the product Papa Kirill was afraid that they would talk badly about his merchandise and his solution was murder. He would change the drug to become lethal on injection. This information was very hard to digest and you ask the waitress for a bottle of vodka. You spend the rest of the night talking about your exploits around the world. A few months later you announce publicly that you are retiring from being an international detective. The media goes crazy and you get a lot of attention for many weeks. You are now running your uncle's restaurant with Octavio Ricca as your right-hand man. You are now lovers and are going to get engaged secretly. Congratulations! You have finished the game.""" else: # enemy["rounds"] == 0: return """Octavio Ricca runs out of dancing points. After the dance, you hug it out. Octavio Ricca invites you to a pub for a drink. You accept and follow him to the Green Tavern. While you are at the pub you learn from Octavio Ricca that Papa Kirill was a very bad man who would deal drugs all around Illinois. His murder was not an act of revenge or hatred but a way of protecting thousands of people. Indeed, not only did Papa Kirill deal the drugs but he also made them in his underground lab; therefore when customers weren't satisfied with the product Papa Kirill was afraid that they would talk badly about his merchandise and his solution was murder. He would change the drug to become lethal on injection. This information was very hard to digest and you ask the waitress for a bottle of vodka. You spend the rest of the night talking about your exploits around the world. A few months later you announce publicly that you are retiring from being an international detective. The media goes crazy and you get a lot of attention for many weeks. You are now running your uncle's restaurant with Octavio Ricca as your right-hand man. You are now lovers and are going to get engaged secretly. Congratulations! You have finished the game.""".format(enemy["name"])