def encounter(SAVE_DATA): ''' Randomly find gold, potions, and scrolls in this encounter''' clear_screen() name = ("bandit", "adventurer", "mercenary") name_plural = ("bandits", "adventurers", "mercenaries") print("You stumbled upon an abandoned " + name[random.randrange(0, len(name))]+" Camp") print("You look around and found some items the " + name_plural[random.randrange(0, len(name_plural))]+" left behind.") gold = random.randrange(SAVE_DATA["player_data"]["level"], SAVE_DATA["player_data"]["level"] * 3) + 10 potions = 0 scrolls = 0 for _ in range(3): if rng(35): potions += 1 if rng(25): scrolls += 1 print("\n\tYou picked up:") print("\t\t"+str(gold)+" gold") SAVE_DATA["player_data"]["item_data"]["gold"] += gold if potions != 0: print("\t\t"+str(potions)+" recovery potions") SAVE_DATA["player_data"]["item_data"]["potions"] += potions if scrolls != 0: print("\t\t"+str(scrolls)+" resurection scrolls") SAVE_DATA["player_data"]["item_data"]["scrolls"] += scrolls SAVE_DATA = gain_exp(3, SAVE_DATA) input("Press any key to continue") clear_screen() return SAVE_DATA
def main_menu(SAVE_DATA): '''main menu to save, load, or exit game''' clear_screen() command = input("N = New Game\nL = Load Game\nX = Exit Game\n") if command.lower() == "n": clear_screen() confirm = input("Overwrite current save file?\nY = Yes\tN = No\n") if confirm.lower() == "y": clear_screen() SAVE_DATA = init_new_game() SAVE_DATA = tutorial(SAVE_DATA) clear_screen() print("Created " + SAVE_DATA["name"] + "'s save file") town(SAVE_DATA) elif confirm.lower() == "n": main_menu(SAVE_DATA) elif command.lower() == "l": SAVE_DATA = load_file() clear_screen() print("Loaded " + SAVE_DATA["name"] + "'s save file") town(SAVE_DATA) elif command.lower() == "x": os._exit(1) else: main_menu(SAVE_DATA)
def rest(SAVE_DATA): '''Restore user hp, energy, and saves game data''' command = input( "Take a rest? This will overwrite the current save file. (Y = confirm)\n" ) if command.lower() == "y": SAVE_DATA["player_data"]["hp"] = SAVE_DATA["player_data"]["max_hp"] SAVE_DATA["player_data"]["energy"] = SAVE_DATA["player_data"][ "max_energy"] save_file(SAVE_DATA) clear_screen() return SAVE_DATA
def use_potion(SAVE_DATA): '''Uses a potion to recover 50% hp''' SAVE_DATA["player_data"]["item_data"]["potions"] -= 1 potion_amt = round(SAVE_DATA["player_data"]["max_hp"] / 2) recovered = potion_amt if potion_amt > SAVE_DATA["player_data"]["max_hp"] \ -SAVE_DATA["player_data"]["hp"]: recovered = SAVE_DATA["player_data"]["max_hp"] \ -SAVE_DATA["player_data"]["hp"] SAVE_DATA["player_data"]["hp"] += recovered clear_screen() print(SAVE_DATA["name"]+" uses a potion to recover "+str(recovered)+" hp") return SAVE_DATA
def ability_tome(SAVE_DATA): '''gives the option to replace the current ability, or consume the tome for ability experience * returns SAVE_DATA''' ability = new_ability() print("You have found an ability tome") input("Press Enter to continue\n") looping = True while looping: looping = False clear_screen() print("Currently known abilities:\n1 = ") print_ability_info(SAVE_DATA["player_data"]["ability_data"]["ability1"]) print("2 = ") print_ability_info(SAVE_DATA["player_data"]["ability_data"]["ability2"]) print("New ability = ") print_ability_info(ability) print("You can consume this ability tome to:") command = input("\tR = replace an existing ability?\n\tL = level up an ability\n") if command.lower() == "r": # replace an ability choice = input("Which ability do you wish to replace?(Press C to Cancel)\n") if choice == "1": # replace ability1 SAVE_DATA["player_data"]["ability_data"]["ability1"] = ability elif choice == "2": # replace ability2 SAVE_DATA["player_data"]["ability_data"]["ability2"] = ability else: looping = True elif command.lower() == "l": # level up an ability choice = input("Which ability do you wish to level?(Press C to Cancel)\n") if choice == "1": # level ability1 SAVE_DATA["player_data"]["ability_data"]["ability1"]["energy"] += 3 * SAVE_DATA["player_data"]["ability_data"]["ability1"]["level"] SAVE_DATA["player_data"]["ability_data"]["ability1"]["level"] += 1 elif choice == "2": # level ability2 SAVE_DATA["player_data"]["ability_data"]["ability2"]["energy"] += 3 * SAVE_DATA["player_data"]["ability_data"]["ability2"]["level"] SAVE_DATA["player_data"]["ability_data"]["ability2"]["level"] += 1 else: looping = True return SAVE_DATA
def town(SAVE_DATA): '''Main town menu to visit shop, rest, adventure, or return to main menu''' print("You have arrived at the town.") command = input( "S = Shop\nR = Rest(Save Game)\nA = Adventure\nM = Main Menu\n") if command.lower() == "s": clear_screen() SAVE_DATA = shop(SAVE_DATA) town(SAVE_DATA) elif command.lower() == "r": clear_screen() SAVE_DATA = rest(SAVE_DATA) town(SAVE_DATA) elif command.lower() == "a": clear_screen() SAVE_DATA = adventure(SAVE_DATA) town(SAVE_DATA) elif command.lower() == "m": clear_screen() main_menu(SAVE_DATA) else: clear_screen() town(SAVE_DATA)
def defeat(SAVE_DATA): '''check if player wishes to accept defeat or use a resurrection scroll * returns SAVE_DATA''' clear_screen() selection = "" while selection.lower != "e" or selection.lower() != "r": print("Your hp has fallen to 0\n") if SAVE_DATA["player_data"]["item_data"]["scrolls"] > 0: print("\tR = Resurrect with 25% hp ("+str(SAVE_DATA["player_data"]["item_data"]["scrolls"]) \ +" Ressurection Scrolls available)\n") print("\tE = End battle and return to town") selection = input() if selection.lower() == "r": # resurrect SAVE_DATA["player_data"]["item_data"]["scrolls"] -= 1 SAVE_DATA["player_data"]["hp"] = round(SAVE_DATA["player_data"]["max_hp"] * 0.25) clear_screen() print("You have have been resurrected with "+str(SAVE_DATA["player_data"]["hp"])+" hp") return SAVE_DATA elif selection.lower() == "e": # go to town return SAVE_DATA return SAVE_DATA
def shop_selection(command, SAVE_DATA): ''' allows the player to select which item they wish to buy while checking for sufficient gold.''' # Buying items if command == "0": clear_screen() return SAVE_DATA if command == "1": clear_screen() print("Gold:", SAVE_DATA["player_data"]["item_data"]["gold"]) print("Potions:", SAVE_DATA["player_data"]["item_data"]["potions"]) command = input("How many Healing Potions(25g) do you wish to buy?\n") try: command = int(command) except TypeError: clear_screen() print("Enter a number") shop(SAVE_DATA) cost = (SAVE_DATA["shop_data"]["item1"]["value"]) * command if check_gold(cost, SAVE_DATA): SAVE_DATA["player_data"]["item_data"]["gold"] -= cost else: no_gold() if command == "2": clear_screen() print("Gold:", SAVE_DATA["player_data"]["item_data"]["gold"]) print("Scrolls:", SAVE_DATA["player_data"]["item_data"]["scrolls"]) command = input( "How many Resurrection Scrolls(50g) do you wish to buy?") try: command = int(command) except TypeError: clear_screen() print("Enter a number") shop(SAVE_DATA) cost = SAVE_DATA["shop_data"]["item2"]["value"] * command if check_gold(cost, SAVE_DATA): SAVE_DATA["player_data"]["item_data"]["gold"] -= cost else: no_gold() if command == "3": SAVE_DATA = buy_item("item3", SAVE_DATA) if command == "4": SAVE_DATA = buy_item("item4", SAVE_DATA) if command == "5": SAVE_DATA = buy_item("item5", SAVE_DATA) clear_screen() shop(SAVE_DATA)
def no_gold(): '''to do when cost of item wanted is greater that gold balance''' clear_screen() print("Not enough gold") return
def buy_item(item_num, SAVE_DATA): '''check which item it is, display current equipped counterpart and give option to replace''' if check_gold(SAVE_DATA["shop_data"][item_num]["value"], SAVE_DATA): clear_screen() if SAVE_DATA["shop_data"][item_num]["item"] == "ring": print("Currently equipped rings:\n1 = ") print_ring_info(SAVE_DATA["player_data"]["item_data"]["ring1"]) print("2 = ") print_ring_info(SAVE_DATA["player_data"]["item_data"]["ring2"]) print("New ring = ") print_ring_info(SAVE_DATA["shop_data"][item_num]) command = input( "Which Ring do you wish to replace? (Press C to Cancel)\n") if command == "1": SAVE_DATA = update_stats(SAVE_DATA, SAVE_DATA["shop_data"][item_num], "ring1") SAVE_DATA["player_data"]["item_data"]["gold"] -= \ SAVE_DATA["shop_data"][item_num]["value"] SAVE_DATA["player_data"]["item_data"]["ring1"] = \ SAVE_DATA["shop_data"][item_num] SAVE_DATA["shop_data"][item_num] = None elif command == "2": SAVE_DATA = update_stats(SAVE_DATA, SAVE_DATA["shop_data"][item_num], "ring2") SAVE_DATA["player_data"]["item_data"]["gold"] -= \ SAVE_DATA["shop_data"][item_num]["value"] SAVE_DATA["player_data"]["item_data"]["ring2"] = \ SAVE_DATA["shop_data"][item_num] SAVE_DATA["shop_data"][item_num] = None else: if SAVE_DATA["shop_data"][item_num]["item"] == "armor": print("Currently equipped armor:") print_armor_info( SAVE_DATA["player_data"]["item_data"]["armor"]) print("Replace with this new armor?") print_armor_info(SAVE_DATA["shop_data"][item_num]) command = input("\nY = Confirm\n") if command.lower() == "y": SAVE_DATA = update_stats(SAVE_DATA, SAVE_DATA["shop_data"][item_num], "armor") SAVE_DATA["player_data"]["item_data"]["gold"] -= \ SAVE_DATA["shop_data"][item_num]["value"] SAVE_DATA["player_data"]["item_data"]["armor"] = \ SAVE_DATA["shop_data"][item_num] SAVE_DATA["shop_data"][item_num] = None elif SAVE_DATA["shop_data"][item_num]["item"] == "weapon": print("Currently equipped weapon:") print_weapon_info( SAVE_DATA["player_data"]["item_data"]["weapon"]) print("Replace with this new weapon?") print_weapon_info(SAVE_DATA["shop_data"][item_num]) command = input("\nY = Confirm\n") if command.lower() == "y": SAVE_DATA["player_data"]["item_data"]["gold"] -= \ SAVE_DATA["shop_data"][item_num]["value"] SAVE_DATA["player_data"]["item_data"]["weapon"] = \ SAVE_DATA["shop_data"][item_num] SAVE_DATA["shop_data"][item_num] = None clear_screen() return SAVE_DATA else: no_gold() return SAVE_DATA
def level_up(SAVE_DATA): '''recalculate max stats based on leveling up''' points = 3 health = attack = energy = 0 clear_screen() while points > 0: temp = 0 print("You can increase the following stats "+str(points)+" times:") print("\nH = Health(+"+str(health) + ")\nA = Attack(+"+str(attack) + ")\nE = Energy(+"+str(energy) + ")\n") command = input() if command.lower() == "h": try: temp = int(input("How many points do you want to add to health? (" + str(points) + " points available)\n")) if temp <= points: health += temp points -= temp except Exception: clear_screen() print("Choose a number up to the amount of points available") continue elif command.lower() == "a": try: temp = int(input("How many points do you want to add to attack? (" + str(points)+" points available)\n")) if temp <= points: attack += temp points -= temp except Exception: clear_screen() print("Choose a number up to the amount of points available") continue elif command.lower() == "e": try: temp = int(input("How many points do you want to add to energy? (" + str(points)+" points available)\n")) if temp <= points: energy += temp points -= temp except Exception: clear_screen() print("Choose a number up to the amount of points available") continue else: clear_screen() continue clear_screen() clear_screen() print("You have chosen to increase the following stats:") print("\nH = Health(+"+str(health) + ")\nA = Attack(+"+str(attack) + ")\nE = Energy(+"+str(energy) + ")\n") command = input("Y = Continue\nN = Redistribute points\n") if command.lower() == "y": SAVE_DATA["player_data"]["stats"]["health"] += health + 1 SAVE_DATA["player_data"]["stats"]["attack"] += attack + 1 SAVE_DATA["player_data"]["stats"]["energy"] += energy + 1 else: level_up(SAVE_DATA) # Recalculate hp and energy, and refill to max SAVE_DATA["player_data"]["max_hp"] = \ int(new_max_hp(SAVE_DATA["player_data"]["level"])) + \ SAVE_DATA["player_data"]["stats"]["health"] SAVE_DATA["player_data"]["hp"] = SAVE_DATA["player_data"]["max_hp"] SAVE_DATA["player_data"]["max_energy"] = \ int(new_max_energy(SAVE_DATA["player_data"]["level"])) + \ SAVE_DATA["player_data"]["stats"]["energy"] SAVE_DATA["player_data"]["energy"] = SAVE_DATA["player_data"]["max_energy"] clear_screen() return SAVE_DATA
def victory(SAVE_DATA, ENEMY_DATA): '''calculates victory rewards * returns SAVE_DATA''' print("\n\t\tVICTORY!") input("\nPress Enter to continue") clear_screen() # gain exp based on enemy levels exp_gain = get_max_exp(ENEMY_DATA["enemy1"]["level"]) try: exp_gain = get_max_exp(ENEMY_DATA["enemy2"]["level"]) exp_gain = get_max_exp(ENEMY_DATA["enemy3"]["level"]) except: pass exp_gain = round(exp_gain * 0.05) SAVE_DATA = gain_exp(exp_gain, SAVE_DATA) input("\n\tPress Enter to continue") clear_screen() # check if ability leveled up abilities = ["ability1","ability2"] for x in abilities: max_exp = (50 + (SAVE_DATA["player_data"]["ability_data"][x]["level"])*5) if SAVE_DATA["player_data"]["ability_data"][x]["experience"] > max_exp: SAVE_DATA["player_data"]["ability_data"][x]["experience"] -= max_exp # increase energy cost SAVE_DATA["player_data"]["ability_data"][x]["energy"] += 3 * SAVE_DATA["player_data"]["ability_data"][x]["level"] # increase level of ability SAVE_DATA["player_data"]["ability_data"][x]["level"] += 1 print("Your "+SAVE_DATA["player_data"]["ability_data"][x]["name"]+" has leveled up.") input("\n\tPress Enter to continue") clear_screen() # gain gold based on player level and number of enemies gold_earned = random.randrange(exp_gain*15, exp_gain*50) SAVE_DATA["player_data"]["item_data"]["gold"] += gold_earned print("You have earned "+str(gold_earned)+" gold") input("\n\tPress Enter to continue") clear_screen() # gain item drop based on enemy level print("You have found") if rng(25): item_drop = new_ring(70, 20, 10, SAVE_DATA["player_data"]["level"]) print_ring_info(item_drop) item_drop_type = "ring" elif rng(35, 75): item_drop = new_weapon(70, 20, 10, SAVE_DATA["player_data"]["level"]) print_weapon_info(item_drop) item_drop_type = "weapon" else: item_drop = new_armor(70, 20, 10, SAVE_DATA["player_data"]["level"]) print_armor_info(item_drop) item_drop_type = "armor" input("\n\tPress Enter to continue") clear_screen() # Check to see if player will keep the new item looping = True while looping: if item_drop_type == "ring": print("Currently equipped rings:\n1 = ") print_ring_info(SAVE_DATA["player_data"]["item_data"]["ring1"]) print("2 = ") print_ring_info(SAVE_DATA["player_data"]["item_data"]["ring2"]) print("New ring = ") print_ring_info(item_drop) command = input("Which Ring do you wish to replace? (Enter 'N' to sell the new ring instead)\n") clear_screen() if command == "1": SAVE_DATA = update_stats(SAVE_DATA, item_drop, "ring1") SAVE_DATA["player_data"]["item_data"]["ring1"] = item_drop looping = False elif command == "2": SAVE_DATA = update_stats(SAVE_DATA, item_drop, "ring2") SAVE_DATA["player_data"]["item_data"]["ring2"] = item_drop looping = False elif item_drop_type == "weapon": print("Currently equipped weapon:") print_weapon_info(SAVE_DATA["player_data"]["item_data"]["weapon"]) print("Replace with this new weapon?") print_weapon_info(item_drop) command = input("\nY = Replace\nN = Sell\n") clear_screen() if command.lower() == "y": SAVE_DATA["player_data"]["item_data"]["weapon"] = item_drop looping = False elif item_drop_type == "armor": print("Currently equipped armor:") print_armor_info(SAVE_DATA["player_data"]["item_data"]["armor"]) print("Replace with this new armor?") print_armor_info(item_drop) command = input("\nY = Replace\nN = Sell\n") clear_screen() if command.lower() == "y": SAVE_DATA["player_data"]["item_data"]["armor"] = item_drop SAVE_DATA = update_stats(SAVE_DATA, item_drop, "armor") looping = False if command.lower() == "n":# Sell the item for gold print("You will sell the dropped item for "+str(item_drop["value"])+" gold") command = input("\nY = Confirm\n") if command.lower() == "y": SAVE_DATA["player_data"]["item_data"]["gold"] += item_drop["value"] looping = False clear_screen() else: continue # gain ability tome based on boss drops if ENEMY_DATA["enemy1"]["boss"] == "Y": SAVE_DATA = ability_tome(SAVE_DATA) return SAVE_DATA
def player_attack(SAVE_DATA, ENEMY_DATA, ability_level = 0, method = "basic"): '''Player chooses target * returns ENEMY_DATA''' multiplier = 1 clear_screen() print_battle_menu(SAVE_DATA, ENEMY_DATA) print(""+"―"*80) print("\nChoose a target to attack") try: if ENEMY_DATA["enemy1"]["hp"] > 0: print("\t1: "+ ENEMY_DATA["enemy1"]["name"]) except: pass try: if ENEMY_DATA["enemy2"]["hp"] > 0: print("\t2: "+ ENEMY_DATA["enemy2"]["name"]) except: pass try: if ENEMY_DATA["enemy3"]["hp"] > 0: print("\t3: "+ ENEMY_DATA["enemy3"]["name"]) except: pass print("\n"+"―"*80+"\n") selection = integer_input(1,3) clear_screen() enemy = ["enemy1", "enemy2", "enemy3"] target = enemy[selection-1] if method != "basic": if method == "splash": try: for x in enemy: if x != target: multiplier = 0.75 + (ability_level*0.1) else: multiplier = 1.5 + (ability_level*0.1) damage = round(damage_taken( SAVE_DATA["player_data"]["item_data"]["weapon"], SAVE_DATA["player_data"]["stats"]["attack"], SAVE_DATA["player_data"]["stats"]["dexterity"], ENEMY_DATA[x]["armor"] ) * multiplier) ENEMY_DATA[x]["hp"] -= damage if ENEMY_DATA[x]["hp"] <= 0: ENEMY_DATA[x]["hp"] = 0 if damage > 0: print(SAVE_DATA["name"],"dealt", damage, SAVE_DATA["player_data"]["item_data"]["weapon"]["type"], "damage to", ENEMY_DATA[x]["name"]) else: print(SAVE_DATA["name"]+"'s attack has missed!") except: multiplier = 1.5 + (ability_level*0.1) damage = round(damage_taken( SAVE_DATA["player_data"]["item_data"]["weapon"], SAVE_DATA["player_data"]["stats"]["attack"], SAVE_DATA["player_data"]["stats"]["dexterity"], ENEMY_DATA["enemy1"]["armor"] ) * multiplier) ENEMY_DATA["enemy1"]["hp"] -= damage if ENEMY_DATA["enemy1"]["hp"] <= 0: ENEMY_DATA["enemy1"]["hp"] = 0 if damage > 0: print(SAVE_DATA["name"],"dealt", damage, SAVE_DATA["player_data"]["item_data"]["weapon"]["type"], "damage to", ENEMY_DATA["enemy1"]["name"]) else: print(SAVE_DATA["name"]+"'s attack has missed!") elif method == "single": multiplier = 2 + (ability_level*0.1) damage = round(damage_taken( SAVE_DATA["player_data"]["item_data"]["weapon"], SAVE_DATA["player_data"]["stats"]["attack"], SAVE_DATA["player_data"]["stats"]["dexterity"], ENEMY_DATA[target]["armor"] ) * multiplier) ENEMY_DATA[target]["hp"] -= damage if ENEMY_DATA[target]["hp"] <= 0: ENEMY_DATA[target]["hp"] = 0 if damage > 0: print(SAVE_DATA["name"],"dealt", damage, SAVE_DATA["player_data"]["item_data"]["weapon"]["type"], "damage to", ENEMY_DATA[target]["name"]) else: print(SAVE_DATA["name"]+"'s attack has missed!") else: try: damage = round(damage_taken( SAVE_DATA["player_data"]["item_data"]["weapon"], SAVE_DATA["player_data"]["stats"]["attack"], SAVE_DATA["player_data"]["stats"]["dexterity"], ENEMY_DATA[target]["armor"] ) * multiplier) except: print("Please choose an existing enemy.") return ENEMY_DATA ENEMY_DATA[target]["hp"] -= damage if ENEMY_DATA[target]["hp"] <= 0: ENEMY_DATA[target]["hp"] = 0 if damage > 0: print(SAVE_DATA["name"],"dealt", damage, SAVE_DATA["player_data"]["item_data"]["weapon"]["type"], "damage to", ENEMY_DATA[target]["name"]) else: print(SAVE_DATA["name"]+"'s attack has missed!") return ENEMY_DATA
def battle(SAVE_DATA): '''battle menu display and selection''' ENEMY_DATA = generate_enemies(SAVE_DATA) try: enemy_total_hp = ENEMY_DATA["enemy1"]["hp"] \ + ENEMY_DATA["enemy2"]["hp"] \ + ENEMY_DATA["enemy3"]["hp"] except: enemy_total_hp = ENEMY_DATA["enemy1"]["hp"] clear_screen() while SAVE_DATA["player_data"]["hp"] != 0 and enemy_total_hp != 0: print_battle_menu(SAVE_DATA, ENEMY_DATA) print(""+"―"*80) print("\nChoose an action") print("\t1 = Attack") try: print("\t2 = "+SAVE_DATA["player_data"]["ability_data"]["ability1"]["name"]) except: pass try: print("\t3 = "+SAVE_DATA["player_data"]["ability_data"]["ability2"]["name"]) except: pass print("\t4 = Use Recovery Potion (" \ +str(SAVE_DATA["player_data"]["item_data"]["potions"])+")\n" "\t5 = Run Away") print("\n"+"―"*80+"\n") selection = integer_input(1, 5) if selection == 1: ENEMY_DATA = player_attack(SAVE_DATA, ENEMY_DATA) SAVE_DATA["player_data"]["energy"] += SAVE_DATA["player_data"]["item_data"]["weapon"]["energy"] if SAVE_DATA["player_data"]["energy"] > SAVE_DATA["player_data"]["max_energy"]: SAVE_DATA["player_data"]["energy"] = SAVE_DATA["player_data"]["max_energy"] elif selection == 2: if SAVE_DATA["player_data"]["energy"] >= SAVE_DATA["player_data"]["ability_data"]["ability1"]["energy"]: ENEMY_DATA = player_ability("1", SAVE_DATA, ENEMY_DATA) SAVE_DATA["player_data"]["ability_data"]["ability1"]["experience"] += 1 SAVE_DATA["player_data"]["energy"] -= SAVE_DATA["player_data"]["ability_data"]["ability1"]["energy"] else: clear_screen() print("Not enough Energy") continue elif selection == 3: if SAVE_DATA["player_data"]["energy"] >= SAVE_DATA["player_data"]["ability_data"]["ability2"]["energy"]: ENEMY_DATA = player_ability("2", SAVE_DATA, ENEMY_DATA) SAVE_DATA["player_data"]["ability_data"]["ability2"]["experience"] += 1 SAVE_DATA["player_data"]["energy"] -= SAVE_DATA["player_data"]["ability_data"]["ability2"]["energy"] else: clear_screen() print("Not enough Energy") continue elif selection == 4: if SAVE_DATA["player_data"]["item_data"]["potions"] != 0: SAVE_DATA = use_potion(SAVE_DATA) else: clear_screen() print("You have no more potions. Choose another action") continue elif selection == 5: clear_screen() print("Y = Return to town") print("Type any other key to return to battle") choice = input() clear_screen() if choice.lower() == "y": return SAVE_DATA else: continue enemy_attack(SAVE_DATA, ENEMY_DATA) # check to see if enemy has been defeated enemy_total_hp = ENEMY_DATA["enemy1"]["hp"] try: enemy_total_hp += ENEMY_DATA["enemy2"]["hp"] enemy_total_hp += ENEMY_DATA["enemy3"]["hp"] except: pass if enemy_total_hp == 0: SAVE_DATA = victory(SAVE_DATA, ENEMY_DATA) # check to see if player has been defeated elif SAVE_DATA["player_data"]["hp"] == 0: SAVE_DATA = defeat(SAVE_DATA) return SAVE_DATA