diff --git a/.github/workflows/python_code_style_checks.yaml b/.github/workflows/python_code_style_checks.yaml index 076489f..2bbfdaf 100644 --- a/.github/workflows/python_code_style_checks.yaml +++ b/.github/workflows/python_code_style_checks.yaml @@ -33,4 +33,4 @@ jobs: - name: Install Dependencies run: pip install pycodestyle - name: Style Checks - run : python -m pycodestyle --statistics --count --max-line-length=130 source + run : python -m pycodestyle --max-line-length=130 source diff --git a/source/battle.py b/source/battle.py index 0571b46..5b7c5f7 100644 --- a/source/battle.py +++ b/source/battle.py @@ -16,22 +16,29 @@ turn = True fighting = True + def calculate_player_risk(player, item, enemies_remaining, chosen_enemy, enemy): # get all stats player_hp = player["health"] player_agi = player["agility"] player_prot = player["armor protection"] - player_av_dmg = round(( item[player["held item"]]["damage"] + 1 + item[player["held item"]]["damage"] * item[player["held item"]]["critical hit chance"] * 2.3) / 2, 2 ) + player_av_dmg = round( + ( + ( + item[player["held item"]]["damage"] + 1 + item[player["held item"]]["damage"] + ) * item[player["held item"]]["critical hit chance"] * 2.3 + ) / 2, 2 + ) player_def = item[player["held item"]]["defend"] player_critic_ch = item[player["held item"]]["critical hit chance"] - player_health_cap = 1 # placeholder + player_health_cap = 1 # placeholder enemies_number = enemies_remaining enemy_health = random.randint(chosen_enemy["health"]["min spawning health"], chosen_enemy["health"]["max spawning health"]) enemy_agility = chosen_enemy["agility"] enemy_max_damage = chosen_enemy["damage"]["max damage"] enemy_min_damage = chosen_enemy["damage"]["min damage"] enemy_critical_chance = chosen_enemy["damage"]["critical chance"] - enemy_av_dmg = round(( enemy_max_damage + enemy_min_damage + enemy_max_damage * enemy_critical_chance * 1.8) / 2, 2 ) + enemy_av_dmg = round((enemy_max_damage + enemy_min_damage + enemy_max_damage * enemy_critical_chance * 1.8) / 2, 2) # calculate player health capabilities (how many HP the player can restore) count = 0 @@ -53,13 +60,12 @@ def calculate_player_risk(player, item, enemies_remaining, chosen_enemy, enemy): if item_health_bonus != 0: item_health_bonus = int(item[selected_item]["max bonus"]) / 2 - player_health_cap += current_item_health_restoration player_health_cap += item_health_bonus count += 1 # get differences between player and enemy HP - hp_diff = ( (player_hp + player_health_cap + player_def * 1.5) - ( enemy_health * enemies_number ) ) + hp_diff = ((player_hp + player_health_cap + player_def * 1.5) - (enemy_health * enemies_number)) # dodge formula is if round(random.uniform(.30, player_agility), 2) > enemy_agility / 1.15: # enemy agility / 1.15 @@ -73,19 +79,19 @@ def calculate_player_risk(player, item, enemies_remaining, chosen_enemy, enemy): # player real_enemy_agility = enemy_agility / 1.15 - player_true_dodge_possibilities = ( player_agi - .3 ) * 100 - player_false_dodge_possibilities = ( real_enemy_agility - .3 ) * 100 + player_true_dodge_possibilities = (player_agi - .3) * 100 + player_false_dodge_possibilities = (real_enemy_agility - .3) * 100 player_total_possibilities = player_true_dodge_possibilities + player_false_dodge_possibilities - player_dodge_chance = round(( player_true_dodge_possibilities / player_total_possibilities) * 100) + player_dodge_chance = round((player_true_dodge_possibilities / player_total_possibilities) * 100) # enemy real_player_agility = player_agi / 1.15 - enemy_true_dodge_possibilities = ( enemy_agility - .3 ) * 100 - enemy_false_dodge_possibilities = ( real_player_agility - .3 ) * 100 + enemy_true_dodge_possibilities = (enemy_agility - .3) * 100 + enemy_false_dodge_possibilities = (real_player_agility - .3) * 100 enemy_total_possibilities = enemy_true_dodge_possibilities + enemy_false_dodge_possibilities - enemy_dodge_chance = round(( enemy_true_dodge_possibilities / enemy_total_possibilities ) * 100) + enemy_dodge_chance = round((enemy_true_dodge_possibilities / enemy_total_possibilities) * 100) av_dmg_diff = player_av_dmg - enemy_av_dmg @@ -124,11 +130,11 @@ def calculate_player_risk(player, item, enemies_remaining, chosen_enemy, enemy): enemy_dodged = False while player_turn: # if player health is less than 45% and random formula, defend - if player_fake_health > player_fake_health * ( 45 / 100 ) and round(random.uniform(.20, .60), 2) > .45: + if player_fake_health > player_fake_health * (45 / 100) and round(random.uniform(.20, .60), 2) > .45: defend = 0 defend += random.randint(0, int(item[player["held item"]]["defend"])) * player_fake_agility # defend formula - player_fake_health+= random.randint(0, 3) + player_fake_health += random.randint(0, 3) if player_fake_health > player_fake_health_max: player_fake_health = player_fake_health_max # else, the player attack @@ -136,7 +142,11 @@ def calculate_player_risk(player, item, enemies_remaining, chosen_enemy, enemy): # attack formula enemy_dodged = False player_critical_hit = False - player_critical_hit_chance = round(player_critical_hit_chance / random.uniform(.03, player_critical_hit_chance * 2.8), 2) + player_critical_hit_chance = round( + player_critical_hit_chance / random.uniform( + .03, player_critical_hit_chance * 2.8 + ), 2 + ) if round(random.uniform(.30, enemy_agility), 2) > player_fake_agility / 1.15: enemy_dodged = True if player_critical_hit_chance / random.uniform(.20, .35) < player_critical_hit_chance and not enemy_dodged: @@ -160,13 +170,25 @@ def calculate_player_risk(player, item, enemies_remaining, chosen_enemy, enemy): while not player_turn: # if enemy is still alive if enemy_health > 0: - damage = random.randint(enemy_min_damage, enemy_max_damage) - player_fake_defend * ( player_fake_armor_protection * round(random.uniform(.50, .90), 1) ) + damage = random.randint(enemy_min_damage, enemy_max_damage) - player_fake_defend * ( + player_fake_armor_protection * round( + random.uniform(.50, .90), 1 + ) + ) damage = round(damage) defend = 0 player_dodged = False enemy_critical_hit = False - enemy_critical_hit_chance = round(enemy_fake_critical_hit_chance / random.uniform(.03, enemy_fake_critical_hit_chance * 2.8), 2) - critical_hit_chance_formula = round(enemy_critical_hit_chance / random.uniform(.03, enemy_critical_hit_chance * 2.8), 2) + enemy_critical_hit_chance = round( + enemy_fake_critical_hit_chance / random.uniform( + .03, enemy_fake_critical_hit_chance * 2.8 + ), 2 + ) + critical_hit_chance_formula = round( + enemy_critical_hit_chance / random.uniform( + .03, enemy_critical_hit_chance * 2.8 + ), 2 + ) if enemy_critical_hit_chance / random.uniform(.20, .35) < critical_hit_chance_formula and not enemy_dodged: enemy_critical_hit = True elif round(random.uniform(.30, enemy_agility), 2) > enemy_agility / 1.15: @@ -182,7 +204,6 @@ def calculate_player_risk(player, item, enemies_remaining, chosen_enemy, enemy): someone_died = True player_deaths += 1 - count += 1 # compute percentage of defeat chance @@ -195,12 +216,15 @@ def calculate_player_risk(player, item, enemies_remaining, chosen_enemy, enemy): return defeat_percentage + def encounter_text_show(player, item, enemy, map, map_location, enemies_remaining, lists, defeat_percentage): # import stats global turn, defend, fighting, already_encountered - global enemy_singular, enemy_plural, enemy_max, enemy_health, enemy_max_damage, enemy_min_damage, enemy_agility, enemy_damage, chosen_item + global enemy_singular, enemy_plural, enemy_max + global enemy_health, enemy_max_damage, enemy_min_damage + global enemy_agility, enemy_damage, chosen_item player_agility = player["agility"] - print(" ") # do not merge with possible actions text + print(" ") # do not merge with possible actions text # load and create enemies list type health_color = COLOR_GREEN @@ -239,7 +263,11 @@ def encounter_text_show(player, item, enemy, map, map_location, enemies_remainin health_color = COLOR_STYLE_BRIGHT + COLOR_GREEN sys.stdout.write(f"RISK: {risk}% \n") - sys.stdout.write(f"|{health_color}{remaining_risk_bars * remaining_risk_symbol}{lost_risk_bars * lost_risk_symbol}{COLOR_RESET_ALL}|\n") + sys.stdout.write( + f"|{health_color}{ + remaining_risk_bars * remaining_risk_symbol + }{lost_risk_bars * lost_risk_symbol}{COLOR_RESET_ALL}|\n" + ) sys.stdout.flush() print("[R]un Away, [F]ight, [U]se Item? ") @@ -266,7 +294,7 @@ def encounter_text_show(player, item, enemy, map, map_location, enemies_remainin text_handling.print_separator(text) fighting = True elif startup_action.lower().startswith('f'): - fighting = True + fighting = True elif startup_action.lower().startswith('u'): player_inventory = str(player["inventory"]) player_inventory = player_inventory.replace("'", '') @@ -307,11 +335,17 @@ def encounter_text_show(player, item, enemy, map, map_location, enemies_remainin print("'" + startup_action + "' is not a valid option") fighting = True - print(" ") -def get_enemy_stats(player, item, enemy, map, map_location, lists, choose_rand_enemy, chosen_enemy, chosen_item, enemy_items_number, enemy_total_inventory, enemies_remaining): - global enemy_singular, enemy_plural, enemy_max, enemy_health, enemy_max_damage, enemy_min_damage, enemy_agility, enemy_damage + +def get_enemy_stats( + player, item, enemy, map, map_location, + lists, choose_rand_enemy, chosen_enemy, + chosen_item, enemy_items_number, + enemy_total_inventory, enemies_remaining +): + global enemy_singular, enemy_plural, enemy_max, enemy_health + global enemy_max_damage, enemy_min_damage, enemy_agility, enemy_damage # load enemy stat # enemy stats @@ -328,10 +362,13 @@ def get_enemy_stats(player, item, enemy, map, map_location, lists, choose_rand_e if choose_rand_enemy not in player["enemies list"]: player["enemies list"].append(choose_rand_enemy) + def fight(player, item, enemy, map, map_location, enemies_remaining, lists): # import stats global turn, defend, fighting, already_encountered - global enemy_singular, enemy_plural, enemy_max, enemy_health, enemy_max_damage, enemy_min_damage, enemy_agility, enemy_damage, chosen_item + global enemy_singular, enemy_plural, enemy_max + global enemy_health, enemy_max_damage, enemy_min_damage + global enemy_agility, enemy_damage, chosen_item armor_protection = player["armor protection"] player_agility = player["agility"] # load and create enemies list type @@ -387,9 +424,17 @@ def fight(player, item, enemy, map, map_location, enemies_remaining, lists): health_color_enemy = COLOR_MAGENTA sys.stdout.write(f"PLAYER: {player_health} / {player_max_health}\n") - sys.stdout.write(f"|{health_color}{remaining_health_bars * remaining_health_symbol}{lost_health_bars * lost_health_symbol}{color_default}|\n") + sys.stdout.write( + f"|{health_color}{ + remaining_health_bars * remaining_health_symbol + }{lost_health_bars * lost_health_symbol}{color_default}|\n" + ) sys.stdout.write(f"ENEMY: {enemy_health} / {enemy_max_health}\n") - sys.stdout.write(f"|{health_color_enemy}{remaining_health_bars_enemy * remaining_health_symbol}{lost_health_bars_enemy * lost_health_symbol}{color_default}|") + sys.stdout.write( + f"|{health_color_enemy}{ + remaining_health_bars_enemy * remaining_health_symbol + }{lost_health_bars_enemy * lost_health_symbol}{color_default}|" + ) sys.stdout.flush() action = input("\n[A]ttack, [D]efend, [U]se Item? ") @@ -474,7 +519,11 @@ def fight(player, item, enemy, map, map_location, enemies_remaining, lists): while not turn: # if enemy is still alive if enemy_health > 0: - damage = random.randint(enemy_min_damage, enemy_max_damage) - defend * ( armor_protection * round(random.uniform(.50, .90), 1) ) + damage = random.randint( + enemy_min_damage, enemy_max_damage + ) - defend * ( + armor_protection * round(random.uniform(.50, .90), 1) + ) damage = round(damage) defend = 0 player_dodged = False @@ -506,9 +555,17 @@ def fight(player, item, enemy, map, map_location, enemies_remaining, lists): remaining_health_bars_enemy = round(enemy_health / enemy_max_health * bars) lost_health_bars_enemy = bars - remaining_health_bars_enemy sys.stdout.write(f"PLAYER: {player_health} / {player_max_health}\n") - sys.stdout.write(f"|{health_color}{remaining_health_bars * remaining_health_symbol}{lost_health_bars * lost_health_symbol}{color_default}|\n") + sys.stdout.write(f"|{health_color}{ + remaining_health_bars * remaining_health_symbol + }{ + lost_health_bars * lost_health_symbol + }{color_default}|\n") sys.stdout.write(f"ENEMY: {enemy_health} / {enemy_max_health}\n") - sys.stdout.write(f"|{health_color_enemy}{remaining_health_bars_enemy * remaining_health_symbol}{lost_health_bars_enemy * lost_health_symbol}{color_default}|") + sys.stdout.write(f"|{health_color_enemy}{ + remaining_health_bars_enemy * remaining_health_symbol + }{ + lost_health_bars_enemy * lost_health_symbol + }{color_default}|") sys.stdout.flush() print("\n") player["xp"] += enemy_max * enemy_max_damage / 3 @@ -521,7 +578,6 @@ def fight(player, item, enemy, map, map_location, enemies_remaining, lists): return - still_playing = True # deinitialize colorama diff --git a/source/check_yaml.py b/source/check_yaml.py index abc8c0e..0c4bd1d 100644 --- a/source/check_yaml.py +++ b/source/check_yaml.py @@ -13,6 +13,7 @@ # to access the program config/data folder program_dir = str(appdirs.user_config_dir(appname='Bane-Of-Wargs')) + def check_yaml(file_path): file_type = 'none' with open(file_path, 'r') as f: @@ -44,7 +45,11 @@ def check_yaml(file_path): elif file_path.startswith('saves/'): file_type = 'saves' file_schema = str(f'{program_dir}/game/schemas/{file_type}.yaml') - if file_type == 'drinks' or file_type == 'mounts' or file_type == 'map' or file_type == 'lists' or file_type == 'npcs' or file_type == 'enemies' or file_type == 'dialogs' or file_type == 'missions': + long_files_types = [ + 'drinks', 'mounts', 'map', 'lists', 'npcs', + 'enemies', 'dialogs', 'missions' + ] + if file_type in long_files_types: count = 0 file_len = int(len(list(file))) while count < file_len: @@ -53,7 +58,11 @@ def check_yaml(file_path): schema = yamale.make_schema(file_schema) data = yamale.make_data(content=str(current_object_data)) - logger_sys.log_message(f"INFO: Validating file '{file_path}' data: '{current_object_data}' with schema '{file_schema}'") + logger_sys.log_message( + f"INFO: Validating file '{ + file_path + }' data: '{current_object_data}' with schema '{file_schema}'" + ) yamale.validate(schema, data) count += 1 @@ -81,7 +90,11 @@ def check_yaml(file_path): schema = yamale.make_schema(str(file_schema)) data = yamale.make_data(content=str(current_object_data)) - logger_sys.log_message(f"INFO: Validating file '{file_path}' data: '{current_object_data}' with schema '{file_schema}'") + logger_sys.log_message( + f"INFO: Validating file '{ + file_path + }' data: '{current_object_data}' with schema '{file_schema}'" + ) yamale.validate(schema, data) count += 1 @@ -92,10 +105,14 @@ def check_yaml(file_path): logger_sys.log_message(f"INFO: Validating file '{file_path}' data: '{data}' with schema '{file_schema}'") yamale.validate(schema, data) + def examine(file_path): try: check_yaml(str(file_path)) except Exception as error: - print(COLOR_RED + "ERROR: " + COLOR_RESET_ALL + COLOR_RED + COLOR_STYLE_BRIGHT + "A parsing error in a yaml file has been detected:\n" + COLOR_RESET_ALL + str(error)) + print( + COLOR_RED + "ERROR: " + COLOR_RESET_ALL + COLOR_RED + COLOR_STYLE_BRIGHT + + "A parsing error in a yaml file has been detected:\n" + COLOR_RESET_ALL + str(error) + ) logger_sys.log_message(f"ERROR: A parsing error in a yaml file has been detected:\n{error}") text_handling.exit_game() diff --git a/source/data_handling.py b/source/data_handling.py index 0ee1876..1f2d60f 100644 --- a/source/data_handling.py +++ b/source/data_handling.py @@ -17,6 +17,7 @@ # Handling functions + def load_game_data(which_type, what_plugin=None): # Check if the which_type variable is valid, @@ -25,7 +26,10 @@ def load_game_data(which_type, what_plugin=None): # and stop the program immediately if which_type != 'vanilla' and which_type != 'plugin': logger_sys.log_message(f"ERROR: Yaml data loading inputted key '{which_type}' is not valid --> crashing program") - print(f"{COLOR_RED}ERROR: {COLOR_STYLE_BRIGHT}Yaml data loading inputted key '{which_type}' is not valid --> crashing program{COLOR_RESET_ALL}") + print( + f"{COLOR_RED}ERROR: {COLOR_STYLE_BRIGHT}Yaml" + + f"data loading inputted key '{which_type}' is not valid --> crashing program{COLOR_RESET_ALL}" + ) time.sleep(5) text_handling.exit_game() @@ -81,7 +85,7 @@ def load_game_data(which_type, what_plugin=None): else: logger_sys.log_message(f"INFO: Loading plugin '{what_plugin}' data") check_file = os.path.exists(program_dir + "/plugins/" + what_plugin) - if check_file == False: + if check_file: print(COLOR_RED + COLOR_STYLE_BRIGHT + "ERROR: Couldn't find plugin '" + what_plugin + "'" + COLOR_RESET_ALL) logger_sys.log_message(f"ERROR: Couldn't find plugin '{what_plugin}'") play = 0 @@ -132,5 +136,6 @@ def load_game_data(which_type, what_plugin=None): return map, item, drinks, enemy, npcs, start_player, lists, zone, dialog, mission, mounts + # deinitialize colorama deinit() diff --git a/source/dialog_handling.py b/source/dialog_handling.py index 89e87dd..9f68455 100644 --- a/source/dialog_handling.py +++ b/source/dialog_handling.py @@ -15,6 +15,7 @@ # Functions to handle dialogs + def print_dialog(current_dialog, dialog, preferences, text_replacements_generic, player, drinks): current_dialog_name = current_dialog logger_sys.log_message(f"INFO: Printing dialog '{current_dialog_name}'") @@ -22,7 +23,11 @@ def print_dialog(current_dialog, dialog, preferences, text_replacements_generic, dialog_len = len(current_dialog["phrases"]) if "scene" in current_dialog: current_dialog_scene = str(current_dialog["scene"]) - logger_sys.log_message(f"INFO: Printing dialog '{current_dialog_name}' scene at '{program_dir}/game/imgs/{current_dialog_scene}.txt'") + logger_sys.log_message( + f"INFO: Printing dialog '{ + current_dialog_name + }' scene at '{program_dir}/game/imgs/{current_dialog_scene}.txt'" + ) if preferences["latest preset"]["type"] == 'vanilla': with open(program_dir + '/game/imgs/' + str(current_dialog["scene"]) + '.txt') as f: to_print = str(f.read()) @@ -39,8 +44,15 @@ def print_dialog(current_dialog, dialog, preferences, text_replacements_generic, print(to_print) else: current_plugin = str(preferences["latest preset"]["plugin"]) - logger_sys.log_message(f"INFO: Printing dialog '{current_dialog_name}' scene at '{program_dir}/plugins/{current_plugin}/imgs/{current_dialog_scene}.txt'") - with open(program_dir + '/plugins/' + str(preferences["latest preset"]["plugin"]) + '/imgs/' + str(current_dialog["scene"]) + '.txt') as f: + logger_sys.log_message( + f"INFO: Printing dialog '{ + current_dialog_name + }' scene at '{program_dir}/plugins/{current_plugin}/imgs/{current_dialog_scene}.txt'" + ) + with open( + program_dir + '/plugins/' + str(preferences["latest preset"]["plugin"]) + + '/imgs/' + str(current_dialog["scene"]) + '.txt' + ) as f: to_print = str(f.read()) to_print = to_print.replace('$RED', '\033[0;31m') to_print = to_print.replace('$GREEN', '\033[0;32m') @@ -64,7 +76,7 @@ def print_dialog(current_dialog, dialog, preferences, text_replacements_generic, count += 1 text_handling.print_speech_text_effect(text, preferences) count += 1 - if current_dialog["use actions"] == True: + if current_dialog["use actions"]: logger_sys.log_message(f"INFO: Executing dialog '{current_dialog_name}' actions on the player") actions = current_dialog["actions"] if "give item" in actions: @@ -87,17 +99,29 @@ def print_dialog(current_dialog, dialog, preferences, text_replacements_generic, count += 1 if "health modification" in actions: if "diminution" in actions["health modification"]: - logger_sys.log_message("INFO: Removing " + actions["health modification"]["diminution"] + " hp from the player's health") + logger_sys.log_message( + "INFO: Removing " + actions["health modification"]["diminution"] + + " hp from the player's health" + ) player["health"] -= actions["health modification"]["diminution"] if "augmentation" in actions["health modification"]: - logger_sys.log_message("INFO: Adding " + actions["health modification"]["augmentation"] + " hp from the player's health") + logger_sys.log_message( + "INFO: Adding " + actions["health modification"]["augmentation"] + + " hp from the player's health" + ) player["health"] += actions["health modification"]["augmentation"] if "max health" in actions["health modification"]: if "diminution" in actions["health modification"]["max health"]: - logger_sys.log_message("INFO: Removing " + actions["health modification"]["max health"]["diminution"] + " hp from the player's max health") + logger_sys.log_message( + "INFO: Removing " + actions["health modification"]["max health"]["diminution"] + + " hp from the player's max health" + ) player["max health"] -= actions["health modification"]["max health"]["diminution"] if "augmentation" in actions["health modification"]["max health"]: - logger_sys.log_message("INFO: Adding " + actions["health modification"]["max health"]["augmentation"] + " hp from the player's max health") + logger_sys.log_message( + "INFO: Adding " + actions["health modification"]["max health"]["augmentation"] + + " hp from the player's max health" + ) player["max health"] += actions["health modification"]["max health"]["augmentation"] if "gold modification" in actions: if "diminution" in actions["gold modification"]: diff --git a/source/enemy_handling.py b/source/enemy_handling.py index f75df8e..c1d5b1f 100644 --- a/source/enemy_handling.py +++ b/source/enemy_handling.py @@ -13,6 +13,7 @@ # Handling function + def spawn_enemy(map_location, list_enemies, enemy_number, enemy, item, lists, start_player, map, player): enemies_remaining = enemy_number already_encountered = False @@ -30,7 +31,11 @@ def spawn_enemy(map_location, list_enemies, enemy_number, enemy, item, lists, st logger_sys.log_message("INFO: Calculating battle risk for the player") defeat_percentage = battle.calculate_player_risk(player, item, enemies_remaining, chosen_enemy, enemy) logger_sys.log_message("INFO: Getting enemy stats") - battle.get_enemy_stats(player, item, enemy, map, map_location, lists, choose_rand_enemy, chosen_enemy, chosen_item, enemy_items_number, enemy_total_inventory, enemies_remaining) + battle.get_enemy_stats( + player, item, enemy, map, map_location, lists, choose_rand_enemy, + chosen_enemy, chosen_item, enemy_items_number, + enemy_total_inventory, enemies_remaining + ) if not already_encountered: logger_sys.log_message("INFO: Display enemy encounter text") battle.encounter_text_show(player, item, enemy, map, map_location, enemies_remaining, lists, defeat_percentage) @@ -74,5 +79,6 @@ def spawn_enemy(map_location, list_enemies, enemy_number, enemy, item, lists, st play = 0 return play + # deinitialize colorama deinit() diff --git a/source/logger_sys.py b/source/logger_sys.py index 71a641c..b20f0ab 100644 --- a/source/logger_sys.py +++ b/source/logger_sys.py @@ -2,6 +2,7 @@ import appdirs from datetime import * + def log_message(message): program_dir = str(appdirs.user_config_dir(appname='Bane-Of-Wargs')) diff --git a/source/main.py b/source/main.py index d199c93..77b3965 100644 --- a/source/main.py +++ b/source/main.py @@ -42,6 +42,7 @@ separator = COLOR_STYLE_BRIGHT + "###############################" + COLOR_RESET_ALL + def print_title(): if preferences["theme"] == "OFF": with open(program_dir + '/game/imgs/Title' + str(preferences["title style"]) + '.txt', 'r') as f: @@ -84,12 +85,13 @@ def print_title(): faded_text = fade.random(f.read()) print(faded_text) + menu = True # Check if player has the config folder if # not, create it with all its required content program_dir = str(appdirs.user_config_dir(appname='Bane-Of-Wargs')) -if os.path.exists(program_dir) == False: +if not os.path.exists(program_dir): os.mkdir(program_dir) # Open default config file and store the text into # a variable to write it into the user config file @@ -118,7 +120,7 @@ def print_title(): with open(program_dir + '/preferences.yaml', 'r') as f: preferences = yaml.safe_load(f) check_yaml.examine(program_dir + '/preferences.yaml') -if preferences["auto update"] == True: +if preferences["auto update"]: logger_sys.log_message("INFO: Downloading game data to update it") print("Download game data...") print("This may take a few seconds, sorry for the waiting.") @@ -132,7 +134,11 @@ def print_title(): fs = fsspec.filesystem("github", org="Dungeons-Of-Kathallion", repo="Bane-Of-Wargs") fs.get(fs.ls("schemas/"), destination) except Exception as error: - print(COLOR_YELLOW + COLOR_STYLE_BRIGHT + "WARNING:" + COLOR_RESET_ALL + " an error occurred when trying to download game data to '" + destination + "'.") + print( + COLOR_YELLOW + COLOR_STYLE_BRIGHT + "WARNING:" + COLOR_RESET_ALL + + " an error occurred when trying to download game data to '" + + destination + "'." + ) logger_sys.log_message(f"WARNING: An error occurred when downloading game data to '{destination}'.") logger_sys.log_message("DEBUG: " + str(error)) print(COLOR_YELLOW + str(error) + COLOR_RESET_ALL) @@ -147,7 +153,11 @@ def print_title(): fs = fsspec.filesystem("github", org="Dungeons-Of-Kathallion", repo="Bane-Of-Wargs") fs.get(fs.ls("data/"), destination) except Exception as error: - print(COLOR_YELLOW + COLOR_STYLE_BRIGHT + "WARNING:" + COLOR_RESET_ALL + " an error occurred when trying to download game data to '" + destination + "'.") + print( + COLOR_YELLOW + COLOR_STYLE_BRIGHT + "WARNING:" + + COLOR_RESET_ALL + " an error occurred when trying to download game data to '" + + destination + "'." + ) logger_sys.log_message(f"WARNING: An error occurred when downloading game data to '{destination}'.") logger_sys.log_message("DEBUG: " + str(error)) print(COLOR_YELLOW + str(error) + COLOR_RESET_ALL) @@ -162,7 +172,11 @@ def print_title(): fs = fsspec.filesystem("github", org="Dungeons-Of-Kathallion", repo="Bane-Of-Wargs") fs.get(fs.ls("imgs/"), destination) except Exception as error: - print(COLOR_YELLOW + COLOR_STYLE_BRIGHT + "WARNING:" + COLOR_RESET_ALL + " an error occurred when trying to download game data to '" + destination + "'.") + print( + COLOR_YELLOW + COLOR_STYLE_BRIGHT + "WARNING:" + + COLOR_RESET_ALL + " an error occurred when trying to download game data to '" + + destination + "'." + ) logger_sys.log_message(f"WARNING: An error occurred when downloading game data to '{destination}'.") logger_sys.log_message("DEBUG: " + str(error)) print(COLOR_YELLOW + str(error) + COLOR_RESET_ALL) @@ -188,10 +202,11 @@ def print_title(): assert not repo.bare git = repo.git git.pull() - except: + except Exception: logger_sys.log_message("WARNING: Failed to update game, passing") pass - else: time.sleep(.5) + else: + time.sleep(.5) os.system('clear') print_title() @@ -212,16 +227,22 @@ def print_title(): logger_sys.log_message(f"INFO: Starting game with latest preset: {latest_preset}") using_latest_preset = True if preferences["latest preset"]["type"] == 'vanilla': - map, item, drinks, enemy, npcs, start_player, lists, zone, dialog, mission, mounts = data_handling.load_game_data('vanilla') + ( + map, item, drinks, enemy, npcs, start_player, + lists, zone, dialog, mission, mounts + ) = data_handling.load_game_data('vanilla') else: what_plugin = preferences["latest preset"]["plugin"] - map, item, drinks, enemy, npcs, start_player, lists, zone, dialog, mission, mounts = data_handling.load_game_data('plugin', what_plugin) + ( + map, item, drinks, enemy, npcs, start_player, + lists, zone, dialog, mission, mounts + ) = data_handling.load_game_data('plugin', what_plugin) open_save = preferences["latest preset"]["save"] save_file = program_dir + "/saves/save_" + open_save + ".yaml" check_file = os.path.isfile(save_file) - if check_file == False: + if not check_file: print(COLOR_RED + COLOR_STYLE_BRIGHT + "ERROR: Couldn't find save file '" + save_file + "'" + COLOR_RESET_ALL) logger_sys.log_message(f"ERROR: Couldn't find save file '{save_file}'") play = 0 @@ -243,20 +264,29 @@ def print_title(): for search_for_plugins in os.listdir(program_dir + "/plugins/"): res.append(search_for_plugins) - what_plugin = input(COLOR_STYLE_BRIGHT + "Current plugins: " + COLOR_RESET_ALL + COLOR_GREEN + str(res) + COLOR_RESET_ALL + " ") + what_plugin = input( + COLOR_STYLE_BRIGHT + "Current plugins: " + COLOR_RESET_ALL + + COLOR_GREEN + str(res) + COLOR_RESET_ALL + " " + ) logger_sys.log_message("INFO: Updating latest preset") preferences["latest preset"]["type"] = "plugin" preferences["latest preset"]["plugin"] = what_plugin - map, item, drinks, enemy, npcs, start_player, lists, zone, dialog, mission, mounts = data_handling.load_game_data('plugin', what_plugin) + ( + map, item, drinks, enemy, npcs, start_player, + lists, zone, dialog, mission, mounts + ) = data_handling.load_game_data('plugin', what_plugin) else: logger_sys.log_message("INFO: Updating latest preset") preferences["latest preset"]["type"] = "vanilla" preferences["latest preset"]["plugin"] = "none" - map, item, drinks, enemy, npcs, start_player, lists, zone, dialog, mission, mounts = data_handling.load_game_data('vanilla') + ( + map, item, drinks, enemy, npcs, start_player, + lists, zone, dialog, mission, mounts + ) = data_handling.load_game_data('vanilla') - if using_latest_preset == False: + if not using_latest_preset: text = "Please select an action:" text_handling.print_speech_text_effect(text, preferences) options = ['Open Save', 'New Save'] @@ -281,13 +311,16 @@ def print_title(): text = "Please select a save to open." text_handling.print_speech_text_effect(text, preferences) - open_save = input(COLOR_STYLE_BRIGHT + "Current saves: " + COLOR_RESET_ALL + COLOR_GREEN + str(res) + COLOR_RESET_ALL + " ") + open_save = input( + COLOR_STYLE_BRIGHT + "Current saves: " + COLOR_RESET_ALL + + COLOR_GREEN + str(res) + COLOR_RESET_ALL + " " + ) logger_sys.log_message("INFO: Updating latest preset") preferences["latest preset"]["save"] = open_save save_file = program_dir + "/saves/save_" + open_save + ".yaml" check_file = os.path.isfile(save_file) - if check_file == False: + if not check_file: print(COLOR_RED + COLOR_STYLE_BRIGHT + "ERROR: Couldn't find save file '" + save_file + "'" + COLOR_RESET_ALL) logger_sys.log_message(f"ERROR: Couldn't find save file '{save_file}'") play = 0 @@ -309,8 +342,11 @@ def print_title(): check_file = os.path.isfile(save_name) logger_sys.log_message("INFO: Updating latest preset") preferences["latest preset"]["save"] = "/save_" + enter_save_name + ".yaml" - if check_file == True: - print(COLOR_RED + COLOR_STYLE_BRIGHT + "ERROR: Save file '" + save_name + "'" + " already exists" + COLOR_RESET_ALL) + if check_file: + print( + COLOR_RED + COLOR_STYLE_BRIGHT + "ERROR: Save file '" + + save_name + "'" + " already exists" + COLOR_RESET_ALL + ) logger_sys.log_message(f"ERROR: Save file '{save_name}' already exists") play = 0 text_handling.exit_game() @@ -352,10 +388,17 @@ def print_title(): if choice == 'Edit Save': text = "Please select a save to edit." text_handling.print_speech_text_effect(text, preferences) - open_save = input(COLOR_STYLE_BRIGHT + "Current saves: " + COLOR_RESET_ALL + COLOR_GREEN + str(res) + COLOR_RESET_ALL + " ") + open_save = input( + COLOR_STYLE_BRIGHT + "Current saves: " + COLOR_RESET_ALL + + COLOR_GREEN + str(res) + COLOR_RESET_ALL + " " + ) check_file = os.path.isfile(program_dir + "/saves/save_" + open_save + ".yaml") - if check_file == False: - print(COLOR_RED + COLOR_STYLE_BRIGHT + "ERROR: Save file '" + program_dir + "/saves/save_" + open_save + ".yaml" + "'" + " does not exists" + COLOR_RESET_ALL) + if not check_file: + print( + COLOR_RED + COLOR_STYLE_BRIGHT + "ERROR: Save file '" + + program_dir + "/saves/save_" + open_save + ".yaml" + + "'" + " does not exists" + COLOR_RESET_ALL + ) logger_sys.log_message(f"ERROR: Save file '{program_dir}/saves/save_{open_save}.yaml' does not exists") play = 0 text = "Select an action for the selected save." @@ -364,8 +407,15 @@ def print_title(): choice = term_menu.show_menu(options) if choice == 'Rename Save': rename_name = input("Select a new name for the save: ") - os.rename(program_dir + "/saves/save_" + open_save + ".yaml", program_dir + "/saves/save_" + rename_name + ".yaml") - logger_sys.log_message(f"INFO: Renaming save file '{program_dir}/saves/save_{open_save}.yaml' to '{program_dir}/saves/save_{rename_name}.yaml'") + os.rename( + program_dir + "/saves/save_" + open_save + ".yaml", + program_dir + "/saves/save_" + rename_name + ".yaml" + ) + logger_sys.log_message( + f"INFO: Renaming save file '{program_dir}/saves/save_{ + open_save + }.yaml' to '{program_dir}/saves/save_{rename_name}.yaml'" + ) else: save_to_open = program_dir + "/saves/save_" + open_save + ".yaml" try: @@ -377,15 +427,28 @@ def print_title(): else: text = "Please select a save to delete." text_handling.print_speech_text_effect(text, preferences) - open_save = input(COLOR_STYLE_BRIGHT + "Current saves: " + COLOR_RESET_ALL + COLOR_GREEN + str(res) + COLOR_RESET_ALL + " ") + open_save = input( + COLOR_STYLE_BRIGHT + "Current saves: " + COLOR_RESET_ALL + + COLOR_GREEN + str(res) + COLOR_RESET_ALL + " " + ) check_file = os.path.isfile(program_dir + "/saves/save_" + open_save + ".yaml") - if check_file == False: - print(COLOR_RED + COLOR_STYLE_BRIGHT + "ERROR: Save file '" + program_dir + "/saves/save_" + open_save + ".yaml" + "'" + " does not exists" + COLOR_RESET_ALL) - logger_sys.log_message(f"ERROR: Save file '{prgram_dir}/saves/save_{open_save}.yaml' does not exists") + if not check_file: + print( + COLOR_RED + COLOR_STYLE_BRIGHT + "ERROR: Save file '" + + program_dir + "/saves/save_" + open_save + ".yaml" + + "'" + " does not exists" + COLOR_RESET_ALL + ) + logger_sys.log_message(f"ERROR: Save file '{program_dir}/saves/save_{open_save}.yaml' does not exists") play = 0 check = input("Are you sure you want to delete the following save (y/n)") if check.lower().startswith('y'): - logger_sys.log_message(f"WARNING: Deleting save file '{program_dir}/saves/save_{open_save}.yaml' and save file backup '{program_dir}/saves/~0 save_{open_save}.yaml'") + logger_sys.log_message( + f"WARNING: Deleting save file '{program_dir}/saves/save_{ + open_save + }.yaml' and save file backup '{ + program_dir + }/saves/~0 save_{open_save}.yaml'" + ) os.remove(program_dir + "/saves/save_" + open_save + ".yaml") os.remove(program_dir + "/saves/~0 save_" + open_save + ".yaml") elif choice == 'Preferences': @@ -408,10 +471,17 @@ def print_title(): assert not repo.bare git = repo.git git.pull() - except: - print(COLOR_RED + "ERROR: Could not update repo: something went wrong when pulling. Please try to pull the repo manually on the command line" + COLOR_RESET_ALL) + except Exception: + print( + COLOR_RED + "ERROR: Could not update repo: something went wrong when pulling" + + ". Please try to pull the repo manually on the command line" + COLOR_RESET_ALL + ) logger_sys.log_message("ERROR: Could not update repo: something went wrong when pulling.") - logger_sys.log_message("DEBUG: Please make sure you're playing using the source code from the github repository. You can also try to pull the repo manually from the command line.") + logger_sys.log_message( + "DEBUG: Please make sure you're playing using the source" + + " code from the github repository. You can also try to pull" + + " the repo manually from the command line." + ) time.sleep(5) text = "Finished Updating." text_handling.print_speech_text_effect(text, preferences) @@ -419,6 +489,7 @@ def print_title(): os.system('clear') exit(1) + # function to search through the map file def search(x, y): logger_sys.log_message(f"INFO: Searching for map point corresponding to coordinates x:{x}, y:{y}") @@ -439,12 +510,14 @@ def add_gold(amount): player_gold += float(amount) player["gold"] = round(player_gold, 2) + def remove_gold(amount): logger_sys.log_message(f"INFO: Removing to player {amount} gold") player_gold = player["gold"] player_gold -= float(amount) player["gold"] = round(player_gold, 2) + def check_for_key(direction): logger_sys.log_message("INFO: Checking for key at every next locations possible") map_point_count = int(len(list(map))) @@ -505,7 +578,7 @@ def check_for_key(direction): have_necessary_keys = True if choice == 'Continue': - while count < keys_len and have_necessary_keys == True: + while count < keys_len and have_necessary_keys: chosen_key = map["point" + str(future_map_location)]["key"]["required keys"][int(count)] @@ -535,6 +608,7 @@ def check_for_key(direction): elif direction == "west": player["x"] -= 1 + # Loading text replacements logger_sys.log_message("INFO: Loading generic texts replacements") save_file_name_text_replacements = save_file.replace(program_dir + '/saves/save_', '') @@ -567,6 +641,7 @@ def check_for_key(direction): } logger_sys.log_message(f"INFO: Loaded generic texts replacements: '{text_replacements_generic}'") + def check_for_item(item_name): logger_sys.log_message(f"INFO: Checking if item '{item_name}' actually exists") item_exist = False @@ -574,25 +649,38 @@ def check_for_item(item_name): item_exist = True return item_exist + # gameplay here: def run(play): - if preferences["speed up"] != True: + if not preferences["speed up"]: logger_sys.log_message("INFO: Printing loading menu") print(separator) print(COLOR_GREEN + COLOR_STYLE_BRIGHT + "Reserved keys:" + COLOR_RESET_ALL) - print(COLOR_BLUE + COLOR_STYLE_BRIGHT + "N: "+ COLOR_RESET_ALL + "Go north" + COLOR_RESET_ALL) - print(COLOR_BLUE + COLOR_STYLE_BRIGHT + "S: "+ COLOR_RESET_ALL + "Go south" + COLOR_RESET_ALL) + print(COLOR_BLUE + COLOR_STYLE_BRIGHT + "N: " + COLOR_RESET_ALL + "Go north" + COLOR_RESET_ALL) + print(COLOR_BLUE + COLOR_STYLE_BRIGHT + "S: " + COLOR_RESET_ALL + "Go south" + COLOR_RESET_ALL) print(COLOR_BLUE + COLOR_STYLE_BRIGHT + "E: " + COLOR_RESET_ALL + "Go east" + COLOR_RESET_ALL) print(COLOR_BLUE + COLOR_STYLE_BRIGHT + "W: " + COLOR_RESET_ALL + "Go west" + COLOR_RESET_ALL) print(COLOR_BLUE + COLOR_STYLE_BRIGHT + "D: " + COLOR_RESET_ALL + "Access to your diary.") - print(COLOR_BLUE + COLOR_STYLE_BRIGHT + "I: " + COLOR_RESET_ALL + "View items. When in this view, type the name of an item to examine it." + COLOR_RESET_ALL) - print(COLOR_BLUE + COLOR_STYLE_BRIGHT + "Y: " + COLOR_RESET_ALL + "View mounts. When in this view, type the name of the mount to examine it." + COLOR_RESET_ALL) + print( + COLOR_BLUE + COLOR_STYLE_BRIGHT + "I: " + COLOR_RESET_ALL + + "View items. When in this view, type the name of an item to examine it." + + COLOR_RESET_ALL + ) + print( + COLOR_BLUE + COLOR_STYLE_BRIGHT + "Y: " + COLOR_RESET_ALL + + "View mounts. When in this view, type the name of the mount to examine it." + + COLOR_RESET_ALL + ) print(COLOR_BLUE + COLOR_STYLE_BRIGHT + "Z: " + COLOR_RESET_ALL + "Access to nearest hostel, stable or church.") print(COLOR_BLUE + COLOR_STYLE_BRIGHT + "Q: " + COLOR_RESET_ALL + "Quit game") print(" ") print(COLOR_GREEN + COLOR_STYLE_BRIGHT + "Hints:" + COLOR_RESET_ALL) print("If you find an item on the ground, type the name of the item to take it.") - print("Some items have special triggers, which will often be stated in the description. Others can only be activated in certain situations, like in combat.") + print( + "Some items have special triggers, which will often" + + " be stated in the description. Others can only be activated" + + " in certain situations, like in combat." + ) print(separator) print(" ") @@ -635,7 +723,6 @@ def run(play): # clear text os.system('clear') - # update player ridded mount location: if player["current mount"] in player["mounts"]: map_location = search(player["x"], player["y"]) @@ -657,9 +744,22 @@ def run(play): current_mount_data = player["mounts"][str(player["current mount"])] current_mount_type = str(current_mount_data["mount"]) if current_mount_data["level"] >= 1: - player["mounts"][str(player["current mount"])]["stats"]["agility addition"] = round(mounts[current_mount_type]["stats"]["agility addition"] + ( mounts[current_mount_type]["levels"]["level stat additions"]["agility addition"] * ( round(current_mount_data["level"]) - 1 )), 3) - player["mounts"][str(player["current mount"])]["stats"]["resistance addition"] = round(mounts[current_mount_type]["stats"]["resistance addition"] + ( mounts[current_mount_type]["levels"]["level stat additions"]["resistance addition"] * ( round(current_mount_data["level"]) - 1 )), 3) - + player["mounts"][ + str(player["current mount"]) + ]["stats"]["agility addition"] = round( + mounts[current_mount_type]["stats"]["agility addition"] + + (mounts[current_mount_type]["levels"][ + "level stat additions" + ]["agility addition"] * (round(current_mount_data["level"]) - 1)), 3 + ) + player["mounts"][ + str(player["current mount"]) + ]["stats"]["resistance addition"] = round( + mounts[current_mount_type]["stats"]["resistance addition"] + + (mounts[current_mount_type]["levels"][ + "level stat additions" + ]["resistance addition"] * (round(current_mount_data["level"]) - 1)), 3 + ) logger_sys.log_message("INFO: Verifying player equipped equipment is in the player's inventory") # verify if player worn equipment are in his inventory @@ -680,8 +780,8 @@ def run(play): logger_sys.log_message("INFO: Calculating day time") # calculate day time - day_time = "PLACEHOLDER" # .25 = morning .50 = day .75 = evening .0 = night - day_time_decimal = "." + str(player["elapsed time game days"]).split(".",1)[1] + day_time = "PLACEHOLDER" # .25 = morning .50 = day .75 = evening .0 = night + day_time_decimal = "." + str(player["elapsed time game days"]).split(".", 1)[1] day_time_decimal = float(day_time_decimal) if day_time_decimal < .25 and day_time_decimal > .0: day_time = COLOR_RED + COLOR_STYLE_BRIGHT + "NIGHT" + COLOR_RESET_ALL @@ -692,7 +792,6 @@ def run(play): elif day_time_decimal > .75 and day_time_decimal: day_time = COLOR_YELLOW + COLOR_STYLE_BRIGHT + "EVENING" + COLOR_RESET_ALL - logger_sys.log_message("INFO: Calculating player armor protection stat") # calculate player armor protection # and write it to the save file @@ -704,19 +803,27 @@ def run(play): # loop to get player total armor protection while p: - if count > ( player_items_number - 1 ): + if count > (player_items_number - 1): p = False - if p == True: + if p: player_items_select = player_items[int(count)] - if item[player_items_select]["type"] == "Armor Piece: Chestplate" and player["held chestplate"] == player_items_select: + if item[player_items_select]["type"] == "Armor Piece: Chestplate" and player[ + "held chestplate" + ] == player_items_select: item_armor_protection = item[player_items_select]["armor protection"] - elif item[player_items_select]["type"] == "Armor Piece: Boots" and player["held boots"] == player_items_select: + elif item[player_items_select]["type"] == "Armor Piece: Boots" and player[ + "held boots" + ] == player_items_select: item_armor_protection = item[player_items_select]["armor protection"] - elif item[player_items_select]["type"] == "Armor Piece: Leggings" and player["held leggings"] == player_items_select: + elif item[player_items_select]["type"] == "Armor Piece: Leggings" and player[ + "held leggings" + ] == player_items_select: item_armor_protection = item[player_items_select]["armor protection"] - elif item[player_items_select]["type"] == "Armor Piece: Shield" and player["held shield"] == player_items_select: + elif item[player_items_select]["type"] == "Armor Piece: Shield" and player[ + "held shield" + ] == player_items_select: item_armor_protection = item[player_items_select]["armor protection"] else: item_armor_protection = 0 @@ -742,21 +849,31 @@ def run(play): # loop to get player total agility while p: - if count > ( player_items_number - 1 ): + if count > (player_items_number - 1): p = False - if p == True: + if p: player_items_select = player_items[int(count)] - if item[player_items_select]["type"] == "Armor Piece: Chestplate" and player["held chestplate"] == player_items_select: + if item[player_items_select]["type"] == "Armor Piece: Chestplate" and player[ + "held chestplate" + ] == player_items_select: item_agility = item[player_items_select]["agility"] - elif item[player_items_select]["type"] == "Armor Piece: Boots" and player["held boots"] == player_items_select: + elif item[player_items_select]["type"] == "Armor Piece: Boots" and player[ + "held boots" + ] == player_items_select: item_agility = item[player_items_select]["agility"] - elif item[player_items_select]["type"] == "Armor Piece: Leggings" and player["held leggings"] == player_items_select: + elif item[player_items_select]["type"] == "Armor Piece: Leggings" and player[ + "held leggings" + ] == player_items_select: item_agility = item[player_items_select]["agility"] - elif item[player_items_select]["type"] == "Armor Piece: Shield" and player["held shield"] == player_items_select: + elif item[player_items_select]["type"] == "Armor Piece: Shield" and player[ + "held shield" + ] == player_items_select: item_agility = item[player_items_select]["agility"] - elif item[player_items_select]["type"] == "Weapon" and player["held item"] == player_items_select: + elif item[player_items_select]["type"] == "Weapon" and player[ + "held item" + ] == player_items_select: item_agility = item[player_items_select]["agility"] else: item_agility = 0 @@ -783,9 +900,9 @@ def run(play): # loop to get player total inventory slots while p2: - if count2 > ( player_items_number - 1 ): + if count2 > (player_items_number - 1): p2 = False - if p2 == True: + if p2: player_items_select = player_items[int(count2)] @@ -804,14 +921,24 @@ def run(play): player["inventory slots remaining"] = int(player["inventory slots"]) - int(player_items_number) - map_location = search(player["x"], player["y"]) logger_sys.log_message("INFO: Checking player location is valid") # check player map location - if map_location == None: - text = COLOR_RED + COLOR_STYLE_BRIGHT + "FATAL ERROR: You are in an undefined location. This could have been the result of using or not using a plugin. Verify you are using the right plugin for this save or manually modify your player coordinates in the 'Manage Saves' in the main menu. The game will close in 10 secs." + COLOR_RESET_ALL + if map_location is None: + text = ( + COLOR_RED + COLOR_STYLE_BRIGHT + + "FATAL ERROR: You are in an undefined location. This could have" + + " been the result of using or not using a plugin. Verify you " + + "are using the right plugin for this save or manually modify your " + + "player coordinates in the 'Manage Saves' in the main menu. The game will close in 10 secs." + + COLOR_RESET_ALL + ) logger_sys.log_message("CRITICAL: Player is in an undefined location.") - logger_sys.log_message("DEBUG: This could have been the result of using or not using a plugin. Verify you are using the right plugin for this save or manually modify your player coordinates in the 'Manage Saves' in the main menu.") + logger_sys.log_message( + "DEBUG: This could have been the result of using or not " + + "using a plugin. Verify you are using the right plugin for this " + + "save or manually modify your player coordinates in the 'Manage Saves' in the main menu." + ) text_handling.print_long_string(text) time.sleep(10) os.system('clear') @@ -821,7 +948,11 @@ def run(play): logger_sys.log_message("INFO: Updating player 'map zone' in the save file") player["map zone"] = map_zone - logger_sys.log_message(f"INFO: Checking if player current map point 'point{map_location}' and map zone '{map_zone}' are already known by the player") + logger_sys.log_message( + f"INFO: Checking if player current map point 'point{ + map_location + }' and map zone '{map_zone}' are already known by the player" + ) # add current player location and map # zone to visited areas in the player # save file if there aren't there yet @@ -838,7 +969,11 @@ def run(play): text_handling.print_separator(text) print("DAY TIME: " + day_time) - print("LOCATION: " + map_zone + " (" + COLOR_STYLE_BRIGHT + COLOR_GREEN + str(player["x"]) + COLOR_RESET_ALL + ", " + COLOR_STYLE_BRIGHT + COLOR_GREEN + str(player["y"]) + COLOR_RESET_ALL + ")") + print( + "LOCATION: " + map_zone + " (" + COLOR_STYLE_BRIGHT + COLOR_GREEN + + str(player["x"]) + COLOR_RESET_ALL + ", " + COLOR_STYLE_BRIGHT + COLOR_GREEN + + str(player["y"]) + COLOR_RESET_ALL + ")" + ) text = '=' text_handling.print_separator(text) @@ -853,15 +988,21 @@ def run(play): if "North" not in map["point" + str(map_location)]["blocked"]: print("You can go North ▲" + " " + COLOR_BLUE + COLOR_STYLE_BRIGHT + "I: " + COLOR_RESET_ALL + "View items") else: - print( " " + " " + COLOR_BLUE + COLOR_STYLE_BRIGHT + "I: " + COLOR_RESET_ALL + "View items") + print(" " + " " + COLOR_BLUE + COLOR_STYLE_BRIGHT + "I: " + COLOR_RESET_ALL + "View items") if "South" not in map["point" + str(map_location)]["blocked"]: print("You can go South ▼" + " " + COLOR_BLUE + COLOR_STYLE_BRIGHT + "D: " + COLOR_RESET_ALL + "Check your diary") else: - print( " " + " " + COLOR_BLUE + COLOR_STYLE_BRIGHT + "D: " + COLOR_RESET_ALL + "Check your diary") + print(" " + " " + COLOR_BLUE + COLOR_STYLE_BRIGHT + "D: " + COLOR_RESET_ALL + "Check your diary") if "East" not in map["point" + str(map_location)]["blocked"]: - print("You can go East ►" + " " + COLOR_BLUE + COLOR_STYLE_BRIGHT + "Z: " + COLOR_RESET_ALL + "Interact with zone (hostel...)") + print( + "You can go East ►" + " " + COLOR_BLUE + COLOR_STYLE_BRIGHT + "Z: " + + COLOR_RESET_ALL + "Interact with zone (hostel...)" + ) else: - print(" " + " " + COLOR_BLUE + COLOR_STYLE_BRIGHT + "Z: " + COLOR_RESET_ALL + "Interact with zone (hostel...)") + print( + " " + " " + COLOR_BLUE + COLOR_STYLE_BRIGHT + + "Z: " + COLOR_RESET_ALL + "Interact with zone (hostel...)" + ) if "West" not in map["point" + str(map_location)]["blocked"]: print("You can go West ◄" + " " + COLOR_BLUE + COLOR_STYLE_BRIGHT + "Q: " + COLOR_RESET_ALL + "Quit & save") else: @@ -872,10 +1013,13 @@ def run(play): logger_sys.log_message("INFO: Checking if the start dialog should be displayed to the player") # player start dialog - if player["start dialog"]["heard start dialog"] == False: + if not player["start dialog"]["heard start dialog"]: start_dialog = player["start dialog"]["dialog"] logger_sys.log_message("INFO: Displaying start dialog '{start_dialog}' to player") - dialog_handling.print_dialog(player["start dialog"]["dialog"], dialog, preferences, text_replacements_generic, player, drinks) + dialog_handling.print_dialog( + player["start dialog"]["dialog"], dialog, preferences, + text_replacements_generic, player, drinks + ) text = '=' text_handling.print_separator(text) @@ -888,7 +1032,13 @@ def run(play): is_in_blacksmith = False is_in_forge = False logger_sys.log_message("INFO: Checking if player is in a village, hostel, stable, blacksmith or forge") - if zone[map_zone]["type"] == "village" or zone[map_zone]["type"] == "hostel" or zone[map_zone]["type"] == "stable" or zone[map_zone]["type"] == "blacksmith" or zone[map_zone]["type"] == "forge": + if ( + zone[map_zone]["type"] == "village" + or zone[map_zone]["type"] == "hostel" + or zone[map_zone]["type"] == "stable" + or zone[map_zone]["type"] == "blacksmith" + or zone[map_zone]["type"] == "forge" + ): zone_handling.print_zone_news(zone, map_zone) logger_sys.log_message(f"INFO: Checking if a dialog is defined at map point 'point{map_location}'") if "dialog" in map["point" + str(map_location)] and map_location not in player["heard dialogs"]: @@ -902,8 +1052,12 @@ def run(play): count = 0 required_attributes = dialog[str(current_dialog)]["to display"]["player attributes"] required_attributes_len = len(required_attributes) - logger_sys.log_message(f"INFO: Checking if player has required attributes '{required_attributes}' to display dialog '{current_dialog}'") - while count < required_attributes_len and has_required_attributes == True: + logger_sys.log_message( + f"INFO: Checking if player has required attributes '{ + required_attributes + }' to display dialog '{current_dialog}'" + ) + while count < required_attributes_len and has_required_attributes: selected_attribute = required_attributes[count] if selected_attribute not in player["attributes"]: has_required_attributes = False @@ -913,8 +1067,12 @@ def run(play): count = 0 required_locations = dialog[str(current_dialog)]["to display"]["visited locations"] required_locations_len = len(required_attributes) - logger_sys.log_message(f"INFO: Checking if player has required visited locations '{required_locations}' to display dialog '{current_dialog}'") - while count < required_locations_len and has_required_locations == True: + logger_sys.log_message( + f"INFO: Checking if player has required visited locations '{ + required_locations + }' to display dialog '{current_dialog}'" + ) + while count < required_locations_len and has_required_locations: selected_location = required_locations[count] if selected_location not in player["visited points"]: has_required_locations = False @@ -924,8 +1082,12 @@ def run(play): count = 0 required_enemies = dialog[str(current_dialog)]["to display"]["known enemies"] required_enemies_len = len(required_enemies) - logger_sys.log_message(f"INFO: Checking if player has required known enemies '{required_enemies}' to display dialog '{current_dialog}'") - while count < required_enemies_len and has_required_enemies == True: + logger_sys.log_message( + f"INFO: Checking if player has required known enemies '{ + required_enemies + }' to display dialog '{current_dialog}'" + ) + while count < required_enemies_len and has_required_enemies: selected_enemy = required_enemies[count] if selected_enemy not in player["enemies list"]: has_required_enemies = False @@ -935,21 +1097,35 @@ def run(play): count = 0 required_npcs = dialog[str(current_dialog)]["to display"]["known npcs"] required_npcs_len = len(required_npcs) - logger_sys.log_message(f"INFO: Checking if player has required known npcs '{required_npcs}' to display dialog '{current_dialog}'") - while count < required_npcs_len and has_required_npcs == True: + logger_sys.log_message( + f"INFO: Checking if player has required known npcs '{ + required_npcs + }' to display dialog '{current_dialog}'" + ) + while count < required_npcs_len and has_required_npcs: selected_npc = required_npcs[count] if selected_npc not in player["met npcs names"]: has_required_npcs = False logger_sys.log_message("INFO: Player doesn't have required known npcs to display this dialog") count += 1 if has_required_attributes and has_required_locations and has_required_enemies and has_required_npcs: - logger_sys.log_message(f"INFO: Player has all required stuff to display dialog '{current_dialog}' --> displaying it and adding map location '{map_location}' to the player's heard dialogs save list") + logger_sys.log_message( + f"INFO: Player has all required stuff to display dialog '{ + current_dialog + }' --> displaying it and adding map location '{ + map_location + }' to the player's heard dialogs save list" + ) dialog_handling.print_dialog(current_dialog, dialog, preferences, text_replacements_generic, player, drinks) player["heard dialogs"].append(map_location) text = '=' text_handling.print_separator(text) else: - logger_sys.log_message("INFO: Player doesn't have all required stuff to display dialog '{current_dialog}' --> passing") + logger_sys.log_message( + f"INFO: Player doesn't have all required stuff to display dialog '{ + current_dialog + }' --> passing" + ) logger_sys.log_message("INFO: Checking if the player is in a village") if zone[map_zone]["type"] == "village": is_in_village = True @@ -990,9 +1166,14 @@ def run(play): count = 0 while count < len(list(mission)): current_mission_data = mission[list(mission)[count]] - if int(current_mission_data["source"]) == int(map_location) and str(list(mission)[count]) not in player["offered missions"]: + if int(current_mission_data["source"]) == int(map_location) and str( + list(mission)[count] + ) not in player["offered missions"]: logger_sys.log_message(f"INFO: Offering mission '{str(list(mission)[count])}' to player") - mission_handling.offer_mission(str(list(mission)[count]), player, mission, dialog, preferences, text_replacements_generic, drinks) + mission_handling.offer_mission( + str(list(mission)[count]), player, mission, dialog, + preferences, text_replacements_generic, drinks + ) count += 1 @@ -1001,14 +1182,22 @@ def run(play): # If he does, at the current map location # to the player save to let the program # known that - logger_sys.log_message(f"INFO: Checking if the player has a mission that has a stopover at the current map location '{map_location}'") + logger_sys.log_message( + f"INFO: Checking if the player has a mission that has a stopover at the current map location '{ + map_location + }'" + ) count = 0 while count < len(player["active missions"]): current_mission_data = mission[str(player["active missions"][count])] if "stopovers" in current_mission_data: if map_location in current_mission_data["stopovers"]: - logger_sys.log_message(f"INFO: Adding current map location '{map_location}' to player active mission data '{current_mission_data}'") + logger_sys.log_message( + f"INFO: Adding current map location '{ + map_location + }' to player active mission data '{current_mission_data}'" + ) player["missions"][str(player["active missions"][count])]["stopovers went"].append(map_location) count += 1 @@ -1023,21 +1212,30 @@ def run(play): while count < len(player["active missions"]): current_mission_data = mission[str(player["active missions"][count])] if "stopovers" in current_mission_data: - if len(player["missions"][str(player["active missions"][count])]["stopovers went"]) == len(current_mission_data["stopovers"]): + if len( + player["missions"][str(player["active missions"][count])]["stopovers went"] + ) == len(current_mission_data["stopovers"]): player["missions"][str(player["active missions"][count])]["went to all stopovers"] = True count += 1 # Check if player has a mission that requires to # be at current map location to complete - logger_sys.log_message(f"INFO: Checking if the player has a mission that requires to be at current map location '{map_location}' to complete") + logger_sys.log_message( + f"INFO: Checking if the player has a mission that requires to be at current map location '{ + map_location + }' to complete" + ) count = 0 while count < len(player["active missions"]): current_mission_data = mission[str(player["active missions"][count])] if current_mission_data["destination"] == map_location: logger_sys.log_message(f"INFO: Running mission completing checks for mission data '{current_mission_data}'") - mission_handling.mission_completing_checks(str(player["active missions"][count]), mission, player, dialog, preferences, text_replacements_generic, drinks) + mission_handling.mission_completing_checks( + str(player["active missions"][count]), mission, player, + dialog, preferences, text_replacements_generic, drinks + ) count += 1 @@ -1054,10 +1252,16 @@ def run(play): current_mission_data = mission[str(player["active missions"][count])] if "to fail" in current_mission_data: fail = mission_handling.mission_checks(current_mission_data, player, 'to fail') - if fail == False: + if not fail: logger_sys.log_message(f"INFO: Executing failing triggers of mission data '{current_mission_data}'") - mission_handling.execute_triggers(current_mission_data, player, 'on fail', dialog, preferences, text_replacements_generic, drinks) - print(COLOR_RED + COLOR_STYLE_BRIGHT + "You failed mission '" + current_mission_data["name"] + "'" + COLOR_RESET_ALL) + mission_handling.execute_triggers( + current_mission_data, player, 'on fail', dialog, preferences, + text_replacements_generic, drinks + ) + print( + COLOR_RED + COLOR_STYLE_BRIGHT + "You failed mission '" + + current_mission_data["name"] + "'" + COLOR_RESET_ALL + ) player["active missions"].remove(str(player["active missions"][count])) count += 1 @@ -1067,7 +1271,11 @@ def run(play): # Check if player current missions # have an enemy at current map point - logger_sys.log_message(f"INFO: Checking if the player has a mission that makes an enemy spawn at current map point 'point{map_location}'") + logger_sys.log_message( + f"INFO: Checking if the player has a mission that makes an enemy spawn at current map point 'point{ + map_location + }'" + ) count = 0 count2 = 0 @@ -1084,11 +1292,21 @@ def run(play): spawning_checks = mission_handling.mission_checks(current_enemy_data, player, 'to spawn') if 'to despawn' in current_enemy_data: spawning_checks_2 = mission_handling.mission_checks(current_enemy_data, player, 'to despawn') - if spawning_checks == True and spawning_checks_2 == False: - logger_sys.log_message(f"INFO: Spawning enemy from mission '{current_mission_id}' with mission enemy data '{current_enemy_data}'") - enemy_handling.spawn_enemy(map_location, lists[str(current_enemy_data["enemy category"])], current_enemy_data["enemy number"],enemy, item, lists, start_player, map, player) + if spawning_checks and spawning_checks_2: + logger_sys.log_message( + f"INFO: Spawning enemy from mission '{ + current_mission_id + }' with mission enemy data '{current_enemy_data}'" + ) + enemy_handling.spawn_enemy( + map_location, lists[str(current_enemy_data["enemy category"])], + current_enemy_data["enemy number"], enemy, item, lists, start_player, map, player + ) if "dialog" in current_enemy_data: - dialog_handling.print_dialog(current_enemy_data["dialog"], dialog, preferences, text_replacements_generic, player, drinks) + dialog_handling.print_dialog( + current_enemy_data["dialog"], dialog, preferences, + text_replacements_generic, player, drinks + ) count2 += 1 count += 1 @@ -1096,14 +1314,27 @@ def run(play): logger_sys.log_message(f"INFO: Checking if an enemy at map point 'point{map_location}'") if "enemy" in map["point" + str(map_location)] and map_location not in player["defeated enemies"]: logger_sys.log_message(f"INFO: Found enemies at map point 'point{map_location}'") - enemy_handling.spawn_enemy(map_location, lists[map["point" + str(map_location)]["enemy type"]], map["point" + str(map_location)]["enemy"], enemy, item, lists, start_player, map, player) - - elif day_time == COLOR_RED + COLOR_STYLE_BRIGHT + "NIGHT" + COLOR_RESET_ALL and round(random.uniform(.20, .80), 3) > .7 and zone[map_zone]["type"] != "hostel" and zone[map_zone]["type"] != "stable" and zone[map_zone]["type"] != "village" and zone[map_zone]["type"] != "blacksmith" and zone[map_zone]["type"] != "forge": + enemy_handling.spawn_enemy( + map_location, lists[map["point" + str(map_location)]["enemy type"]], + map["point" + str(map_location)]["enemy"], enemy, item, lists, start_player, map, player + ) + + elif ( + day_time == COLOR_RED + COLOR_STYLE_BRIGHT + "NIGHT" + COLOR_RESET_ALL + and round(random.uniform(.20, .80), 3) > .7 and zone[map_zone]["type"] != "hostel" + and zone[map_zone]["type"] != "stable" and zone[map_zone]["type"] != "village" + and zone[map_zone]["type"] != "blacksmith" and zone[map_zone]["type"] != "forge" + ): logger_sys.log_message("INFO: Checking if it's night time") - logger_sys.log_message("INFO: Checking if the player isn't in a village, an hostel, a stable, a blacksmith or a forge") + logger_sys.log_message( + "INFO: Checking if the player isn't in a village, an hostel, a stable, a blacksmith or a forge" + ) logger_sys.log_message("INFO: Calculating random chance of enemy spawning") logger_sys.log_message("INFO: Spawning enemies") - enemy_handling.spawn_enemy(map_location, lists['generic'], round(random.uniform(1, 5)), enemy, item, lists, start_player, map, player) + enemy_handling.spawn_enemy( + map_location, lists['generic'], round(random.uniform(1, 5)), enemy, + item, lists, start_player, map, player + ) command = input(COLOR_GREEN + COLOR_STYLE_BRIGHT + "> " + COLOR_RESET_ALL) print(" ") logger_sys.log_message(f"INFO: Player ran command '{command}'") @@ -1181,7 +1412,10 @@ def run(play): text_handling.print_separator(text) logger_sys.log_message("INFO: Displaying player diary menu") print("ADVENTURER NAME: " + str(preferences["latest preset"]["save"])) - print("ELAPSED DAYS: " + COLOR_STYLE_BRIGHT + COLOR_MAGENTA + str(round(player["elapsed time game days"], 1)) + COLOR_RESET_ALL) + print( + "ELAPSED DAYS: " + COLOR_STYLE_BRIGHT + COLOR_MAGENTA + + str(round(player["elapsed time game days"], 1)) + COLOR_RESET_ALL + ) text = '=' text_handling.print_separator(text) options = ['Visited Places', 'Encountered Monsters', 'Encountered People', 'Tasks'] @@ -1208,7 +1442,11 @@ def run(play): print("NAME: " + zone[which_zone]["name"]) if zone[which_zone]["type"] == "village": village_point = zone[which_zone]["location"] - village_coordinates = "(" + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(map["point" + str(village_point)]["x"]) + COLOR_RESET_ALL + ", " + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(map["point" + str(village_point)]["y"]) + COLOR_RESET_ALL + ")" + village_coordinates = ( + "(" + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(map["point" + str(village_point)]["x"]) + + COLOR_RESET_ALL + ", " + COLOR_GREEN + COLOR_STYLE_BRIGHT + + str(map["point" + str(village_point)]["y"]) + COLOR_RESET_ALL + ")" + ) print("LOCATION: " + village_coordinates) content_hostels = str(zone[which_zone]["content"]["hostels"]) content_hostels = content_hostels.replace('[', '') @@ -1225,9 +1463,16 @@ def run(play): elif zone[which_zone]["type"] == "hostel": current_hostel = zone[which_zone] hostel_point = zone[which_zone]["location"] - hostel_coordinates = "(" + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(map["point" + str(hostel_point)]["x"]) + COLOR_RESET_ALL + ", " + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(map["point" + str(hostel_point)]["y"]) + COLOR_RESET_ALL + ")" + hostel_coordinates = ( + "(" + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(map["point" + str(hostel_point)]["x"]) + + COLOR_RESET_ALL + ", " + COLOR_GREEN + COLOR_STYLE_BRIGHT + + str(map["point" + str(hostel_point)]["y"]) + COLOR_RESET_ALL + ")" + ) print("LOCATION: " + hostel_coordinates) - print("SLEEP COST: " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(current_hostel["sleep gold"]) + COLOR_RESET_ALL) + print( + "SLEEP COST: " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(current_hostel["sleep gold"]) + COLOR_RESET_ALL + ) if "None" not in current_hostel["sells"]["drinks"]: print("DRINKS SELLS:") count = 0 @@ -1235,7 +1480,12 @@ def run(play): hostel_drinks_len = len(hostel_drinks) while count < hostel_drinks_len: current_drink = str(current_hostel["sells"]["drinks"][int(count)]) - print(" -" + current_hostel["sells"]["drinks"][int(count)] + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(drinks[current_drink]["gold"] * current_hostel["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + current_hostel["sells"]["drinks"][int(count)] + " " + + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(round(drinks[current_drink]["gold"] * current_hostel["cost value"], 2)) + + COLOR_RESET_ALL + ) count += 1 if "None" not in current_hostel["sells"]["items"]: print("ITEMS SELLS") @@ -1244,7 +1494,12 @@ def run(play): hostel_items_len = len(hostel_items) while count < hostel_items_len: current_item = str(current_hostel["sells"]["items"][int(count)]) - print(" -" + current_hostel["sells"]["items"][int(count)] + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(item[current_item]["gold"] * current_hostel["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + current_hostel["sells"]["items"][int(count)] + " " + + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(round(item[current_item]["gold"] * current_hostel["cost value"], 2)) + + COLOR_RESET_ALL + ) count += 1 if "None" not in current_hostel["buys"]["items"]: print("ITEMS BUYS:") @@ -1253,15 +1508,31 @@ def run(play): hostel_items_len = len(hostel_items) while count < hostel_items_len: current_item = str(current_hostel["buys"]["items"][int(count)]) - print(" -" + current_hostel["buys"]["items"][int(count)] + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(item[current_item]["gold"] * current_hostel["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + current_hostel["buys"]["items"][int(count)] + " " + + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(round(item[current_item]["gold"] * current_hostel["cost value"], 2)) + + COLOR_RESET_ALL + ) count += 1 elif zone[which_zone]["type"] == "stable": current_stable = zone[which_zone] stable_point = zone[which_zone]["location"] - stable_coordinates = "(" + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(map["point" + str(stable_point)]["x"]) + COLOR_RESET_ALL + ", " + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(map["point" + str(stable_point)]["y"]) + COLOR_RESET_ALL + ")" + stable_coordinates = ( + "(" + COLOR_GREEN + COLOR_STYLE_BRIGHT + + str(map["point" + str(stable_point)]["x"]) + COLOR_RESET_ALL + ", " + + COLOR_GREEN + COLOR_STYLE_BRIGHT + + str(map["point" + str(stable_point)]["y"]) + COLOR_RESET_ALL + ")" + ) print("LOCATION: " + stable_coordinates) - print("DEPOSIT COST/DAY: " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(current_stable["deposit gold"]) + COLOR_RESET_ALL) - print("TRAINING COST/DAY: " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(current_stable["training gold"]) + COLOR_RESET_ALL) + print( + "DEPOSIT COST/DAY: " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(current_stable["deposit gold"]) + COLOR_RESET_ALL + ) + print( + "TRAINING COST/DAY: " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(current_stable["training gold"]) + COLOR_RESET_ALL + ) options = ['Train Mount', ''] if "None" not in current_stable["stable"]["sells"]["mounts"]: print("MOUNTS SELLS:") @@ -1270,7 +1541,12 @@ def run(play): stable_mounts_len = len(stable_mounts) while count < stable_mounts_len: current_mount = str(current_stable["stable"]["sells"]["mounts"][int(count)]) - print(" -" + current_stable["stable"]["sells"]["mounts"][int(count)] + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(mounts[current_mount]["gold"] * current_stable["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + current_stable["stable"]["sells"]["mounts"][int(count)] + " " + + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(round(mounts[current_mount]["gold"] * current_stable["cost value"], 2)) + + COLOR_RESET_ALL + ) count += 1 if "None" not in current_stable["stable"]["sells"]["items"]: options += ['Buy Item'] @@ -1280,7 +1556,12 @@ def run(play): stable_items_len = len(stable_items) while count < stable_items_len: current_mount = str(current_stable["stable"]["sells"]["items"][int(count)]) - print(" -" + current_stable["stable"]["sells"]["items"][int(count)] + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(item[current_mount]["gold"] * current_stable["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + current_stable["stable"]["sells"]["items"][int(count)] + " " + + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(round(item[current_mount]["gold"] * current_stable["cost value"], 2)) + + COLOR_RESET_ALL + ) count += 1 deposited_mounts_num = 0 count = 0 @@ -1288,12 +1569,15 @@ def run(play): deposited_mounts_names = [] if "None" not in list(player["mounts"]): while count < mounts_list_len: - selected_mount = list(player["mounts"])[count] - selected_mount = str(selected_mount) - if player["mounts"][selected_mount]["location"] == "point" + str(map_location) and player["mounts"][selected_mount]["is deposited"] == True: - deposited_mounts_num += 1 - deposited_mounts_names += [str(player["mounts"][selected_mount]["name"])] - count += 1 + selected_mount = list(player["mounts"])[count] + selected_mount = str(selected_mount) + if ( + player["mounts"][selected_mount]["location"] == "point" + + str(map_location) and player["mounts"][selected_mount]["is deposited"] + ): + deposited_mounts_num += 1 + deposited_mounts_names += [str(player["mounts"][selected_mount]["name"])] + count += 1 else: deposited_mounts_names = 0 deposited_mounts_num = 0 @@ -1303,13 +1587,24 @@ def run(play): deposited_mounts_names = deposited_mounts_names.replace("'", COLOR_GREEN + COLOR_STYLE_BRIGHT) deposited_mounts_names = deposited_mounts_names.replace(',', COLOR_RESET_ALL + ',') if deposited_mounts_num == 0: - print("MOUNTS DEPOSITED HERE: " + COLOR_BLUE + COLOR_STYLE_BRIGHT + str(deposited_mounts_num) + COLOR_RESET_ALL) + print( + "MOUNTS DEPOSITED HERE: " + COLOR_BLUE + COLOR_STYLE_BRIGHT + + str(deposited_mounts_num) + COLOR_RESET_ALL + ) else: - print("MOUNTS DEPOSITED HERE: " + COLOR_BLUE + COLOR_STYLE_BRIGHT + str(deposited_mounts_num) + COLOR_RESET_ALL + " " + deposited_mounts_names) + print( + "MOUNTS DEPOSITED HERE: " + COLOR_BLUE + COLOR_STYLE_BRIGHT + + str(deposited_mounts_num) + COLOR_RESET_ALL + " " + deposited_mounts_names + ) elif zone[which_zone]["type"] == "blacksmith": current_black_smith = zone[which_zone] blacksmith_point = zone[which_zone]["location"] - black_smith_coordinates = "(" + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(map["point" + str(blacksmith_point)]["x"]) + COLOR_RESET_ALL + ", " + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(map["point" + str(blacksmith_point)]["y"]) + COLOR_RESET_ALL + ")" + black_smith_coordinates = ( + "(" + COLOR_GREEN + COLOR_STYLE_BRIGHT + + str(map["point" + str(blacksmith_point)]["x"]) + + COLOR_RESET_ALL + ", " + COLOR_GREEN + COLOR_STYLE_BRIGHT + + str(map["point" + str(blacksmith_point)]["y"]) + COLOR_RESET_ALL + ")" + ) print("LOCATION: " + black_smith_coordinates) if "None" not in current_black_smith["blacksmith"]["buys"]: print("EQUIPMENT BUYS:") @@ -1318,7 +1613,11 @@ def run(play): weapon_buys_len = len(weapon_buys) while count < weapon_buys_len: current_weapon = str(current_black_smith["blacksmith"]["buys"][int(count)]) - print(" -" + current_weapon + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(item[current_weapon]["gold"] * current_black_smith["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + current_weapon + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(round(item[current_weapon]["gold"] * current_black_smith["cost value"], 2)) + + COLOR_RESET_ALL + ) count += 1 if "None" not in current_black_smith["blacksmith"]["orders"]: print("WEAPON ORDERS:") @@ -1327,7 +1626,9 @@ def run(play): weapon_orders_len = len(weapon_orders) while count < weapon_orders_len: current_weapon = str(list(current_black_smith["blacksmith"]["orders"])[int(count)]) - current_weapon_materials = current_black_smith["blacksmith"]["orders"][current_weapon]["needed materials"] + current_weapon_materials = current_black_smith["blacksmith"]["orders"][ + current_weapon + ]["needed materials"] count2 = 0 global_current_weapon_materials = [] current_weapon_materials_num = len(current_weapon_materials) @@ -1349,7 +1650,11 @@ def run(play): while count3 < global_current_weapon_materials.count(current_material): global_current_weapon_materials.remove(current_material) count3 += 1 - global_current_weapon_materials = [sub.replace(current_material, current_material + "X" + current_material_number) for sub in global_current_weapon_materials] + global_current_weapon_materials = [ + sub.replace( + current_material, current_material + "X" + current_material_number + ) for sub in global_current_weapon_materials + ] count2 += 1 @@ -1357,7 +1662,13 @@ def run(play): global_current_weapon_materials = global_current_weapon_materials.replace("'", '') global_current_weapon_materials = global_current_weapon_materials.replace("[", '') global_current_weapon_materials = global_current_weapon_materials.replace("]", '') - print(" -" + current_weapon + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(item[current_weapon]["gold"] * current_black_smith["cost value"], 2)) + COLOR_RESET_ALL + COLOR_GREEN + COLOR_STYLE_BRIGHT + " (" + COLOR_RESET_ALL + global_current_weapon_materials + COLOR_GREEN + COLOR_STYLE_BRIGHT + ")" + COLOR_RESET_ALL) + print( + " -" + current_weapon + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(round(item[current_weapon]["gold"] * current_black_smith["cost value"], 2)) + + COLOR_RESET_ALL + COLOR_GREEN + COLOR_STYLE_BRIGHT + " (" + + COLOR_RESET_ALL + global_current_weapon_materials + + COLOR_GREEN + COLOR_STYLE_BRIGHT + ")" + COLOR_RESET_ALL + ) count += 1 elif zone[which_zone]["type"] == "forge": current_forge = zone[which_zone] @@ -1372,7 +1683,11 @@ def run(play): metal_buys_len = len(metal_buys) while count < metal_buys_len: current_metal = str(metal_buys[count]) - print(" -" + current_metal + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(item[current_metal]["gold"] * current_forge["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + current_metal + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(round(item[current_metal]["gold"] * current_forge["cost value"], 2)) + + COLOR_RESET_ALL + ) count += 1 if "None" not in current_forge["forge"]["sells"]: print("METAL SELLS:") @@ -1381,7 +1696,11 @@ def run(play): metal_sells_len = len(metal_sells) while count < metal_sells_len: current_metal = str(metal_sells[count]) - print(" -" + current_metal + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(item[current_metal]["gold"] * current_forge["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + current_metal + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(round(item[current_metal]["gold"] * current_forge["cost value"], 2)) + + COLOR_RESET_ALL + ) count += 1 text = "DESCRIPTION: " + zone[which_zone]["description"] text_handling.print_long_string(text) @@ -1422,8 +1741,12 @@ def run(play): print("NAME: " + which_enemy) print("PLURAL: " + enemy[which_enemy]["plural"]) - enemy_average_damage = ( enemy[which_enemy]["damage"]["min damage"] + enemy[which_enemy]["damage"]["max damage"] ) / 2 - enemy_average_health = ( enemy[which_enemy]["health"]["min spawning health"] + enemy[which_enemy]["health"]["max spawning health"] ) / 2 + enemy_average_damage = ( + enemy[which_enemy]["damage"]["min damage"] + enemy[which_enemy]["damage"]["max damage"] + ) / 2 + enemy_average_health = ( + enemy[which_enemy]["health"]["min spawning health"] + enemy[which_enemy]["health"]["max spawning health"] + ) / 2 print("AVERAGE DAMAGE: " + COLOR_STYLE_BRIGHT + COLOR_CYAN + str(enemy_average_damage) + COLOR_RESET_ALL) print("AVERAGE HEALTH: " + COLOR_STYLE_BRIGHT + COLOR_RED + str(enemy_average_health) + COLOR_RESET_ALL) print("AGILITY: " + COLOR_STYLE_BRIGHT + COLOR_MAGENTA + str(enemy[which_enemy]["agility"]) + COLOR_RESET_ALL) @@ -1475,8 +1798,10 @@ def run(play): print("NAME: " + which_npc) - - print("COST VALUE: " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(npcs[which_npc]["cost value"]) + COLOR_RESET_ALL) + print( + "COST VALUE: " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(npcs[which_npc]["cost value"]) + COLOR_RESET_ALL + ) sells_list_drinks = str(npcs[which_npc]["sells"]["drinks"]) sells_list_items = str(npcs[which_npc]["sells"]["items"]) buys_list = str(npcs[which_npc]["buys"]["items"]) @@ -1516,7 +1841,7 @@ def run(play): elif choice == 'Tasks': print("ACTIVE TASKS:") tasks_list = player["active missions"] - if tasks_list == None: + if tasks_list is None: tasks_list = ["You have no tasks"] logger_sys.log_message(f"INFO: Printing player active missions: '{tasks_list}'") @@ -1555,7 +1880,11 @@ def run(play): mission_handling.print_description(mission[mission_id], map) destination_point = map["point" + str(mission[mission_id]["destination"])] - destination = str("X:" + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(destination_point["x"]) + COLOR_RESET_ALL + ", Y:" + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(destination_point["y"]) + COLOR_RESET_ALL) + destination = str( + "X:" + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(destination_point["x"]) + + COLOR_RESET_ALL + ", Y:" + COLOR_GREEN + COLOR_STYLE_BRIGHT + + str(destination_point["y"]) + COLOR_RESET_ALL + ) print("") print("DESTINATION: " + destination) @@ -1565,7 +1894,9 @@ def run(play): count = 0 while count < len(mission_stopovers): current_map_point_data = map["point" + str(mission_stopovers[count])] - current_map_point_coordinates = "[X:" + str(current_map_point_data["x"]) + ",Y:" + str(current_map_point_data["y"]) +"]" + current_map_point_coordinates = "[X:" + str( + current_map_point_data["x"] + ) + ",Y:" + str(current_map_point_data["y"]) + "]" new_mission_stopovers.append(current_map_point_coordinates) count += 1 @@ -1589,10 +1920,27 @@ def run(play): text = '=' text_handling.print_separator(text) logger_sys.log_message(f"INFO: Printing player armor protection, agility and critical hit chance stats") - print("ARMOR PROTECTION: " + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(player["armor protection"]) + COLOR_RESET_ALL + COLOR_RED + COLOR_STYLE_BRIGHT + " (" + COLOR_RESET_ALL + "More it's higher, the less you'll take damages in fights" + COLOR_RED + COLOR_STYLE_BRIGHT + ")" + COLOR_RESET_ALL) - print("AGILITY: " + COLOR_MAGENTA + COLOR_STYLE_BRIGHT + str(player["agility"]) + COLOR_RESET_ALL + COLOR_RED + COLOR_STYLE_BRIGHT + " (" + COLOR_RESET_ALL + "More it's higher, the more you'll have a chance to dodge attacks" + COLOR_RED + COLOR_STYLE_BRIGHT + ")" + COLOR_RESET_ALL) + print( + "ARMOR PROTECTION: " + COLOR_GREEN + COLOR_STYLE_BRIGHT + + str(player["armor protection"]) + COLOR_RESET_ALL + COLOR_RED + + COLOR_STYLE_BRIGHT + " (" + COLOR_RESET_ALL + + "More it's higher, the less you'll take damages in fights" + COLOR_RED + + COLOR_STYLE_BRIGHT + ")" + COLOR_RESET_ALL + ) + print( + "AGILITY: " + COLOR_MAGENTA + COLOR_STYLE_BRIGHT + str(player["agility"]) + + COLOR_RESET_ALL + COLOR_RED + COLOR_STYLE_BRIGHT + + " (" + COLOR_RESET_ALL + "More it's higher, the more you'll have a chance to dodge attacks" + + COLOR_RED + COLOR_STYLE_BRIGHT + ")" + COLOR_RESET_ALL + ) if player["held item"] != " ": - print("CRITICAL HIT CHANCE: " + COLOR_CYAN + COLOR_STYLE_BRIGHT + str(item[player["held item"]]["critical hit chance"]) + COLOR_RESET_ALL + COLOR_RED + COLOR_STYLE_BRIGHT + " (" + COLOR_RESET_ALL + "More it's higher, the more you'll have a chance to deal critical attacks" + COLOR_RED + COLOR_STYLE_BRIGHT + ")" + COLOR_RESET_ALL) + print( + "CRITICAL HIT CHANCE: " + COLOR_CYAN + COLOR_STYLE_BRIGHT + + str(item[player["held item"]]["critical hit chance"]) + COLOR_RESET_ALL + + COLOR_RED + COLOR_STYLE_BRIGHT + " (" + COLOR_RESET_ALL + + "More it's higher, the more you'll have a chance to deal critical attacks" + + COLOR_RED + COLOR_STYLE_BRIGHT + ")" + COLOR_RESET_ALL + ) print(" ") logger_sys.log_message("INFO: Printing player equipped items") # equipment @@ -1631,31 +1979,74 @@ def run(play): print("TYPE: " + item[which_item]["type"]) text = "DESCRIPTION: " + item[which_item]["description"] text_handling.print_long_string(text) - if item[which_item]["type"] == "Armor Piece: Chestplate" or item[which_item]["type"] == "Armor Piece: Boots" or item[which_item]["type"] == "Armor Piece: Leggings" or item[which_item]["type"] == "Armor Piece: Shield": - text = " Armor pieces can protect you in fights, more the armor protection is higher, the more it protects you." + if ( + item[which_item]["type"] == "Armor Piece: Chestplate" + or item[which_item]["type"] == "Armor Piece: Boots" + or item[which_item]["type"] == "Armor Piece: Leggings" + or item[which_item]["type"] == "Armor Piece: Shield" + ): + text = ( + " Armor pieces can protect you in fights, more " + + "the armor protection is higher, the more it protects you.") text_handling.print_long_string(text) item_next_upgrade = weapon_upgrade_handling.detect_weapon_next_upgrade_items(which_item, item) - print("UPGRADE TIER: " + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(item[which_item]["upgrade tier"]) + COLOR_RESET_ALL + "/" + str(weapon_upgrade_handling.check_weapon_max_upgrade(str(which_item), item))) + print( + "UPGRADE TIER: " + COLOR_GREEN + COLOR_STYLE_BRIGHT + + str(item[which_item]["upgrade tier"]) + COLOR_RESET_ALL + "/" + + str(weapon_upgrade_handling.check_weapon_max_upgrade(str(which_item), item)) + ) print("ITEMS FOR NEXT UPGRADE:\n" + str(item_next_upgrade)) - print("ARMOR PROTECTION: " + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(item[which_item]["armor protection"]) + COLOR_RESET_ALL) + print( + "ARMOR PROTECTION: " + COLOR_GREEN + COLOR_STYLE_BRIGHT + + str(item[which_item]["armor protection"]) + COLOR_RESET_ALL + ) if item[which_item]["type"] == "Metal": - text = " Metals are items that you buy in village forges that you often use to order weapons in blacksmith." + text = ( + " Metals are items that you buy in village " + + "forges that you often use to order weapons in blacksmith." + ) if item[which_item]["type"] == "Primary Material": - text = " Primary materials are items that you can find naturally but that you can also buy from many villages shops." + text = ( + " Primary materials are items that you " + + "can find naturally but that you can also buy from many villages shops." + ) text_handling.print_long_string(text) if item[which_item]["type"] == "Weapon": item_next_upgrade = weapon_upgrade_handling.detect_weapon_next_upgrade_items(which_item, item) - print("UPGRADE TIER: " + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(item[which_item]["upgrade tier"]) + COLOR_RESET_ALL + "/" + str(weapon_upgrade_handling.check_weapon_max_upgrade(str(which_item). item))) + print( + "UPGRADE TIER: " + COLOR_GREEN + COLOR_STYLE_BRIGHT + + str(item[which_item]["upgrade tier"]) + COLOR_RESET_ALL + "/" + + str(weapon_upgrade_handling.check_weapon_max_upgrade(str(which_item). item)) + ) print("ITEMS FOR NEXT UPGRADE:\n" + str(item_next_upgrade)) print("DAMAGE: " + COLOR_CYAN + COLOR_STYLE_BRIGHT + str(item[which_item]["damage"]) + COLOR_RESET_ALL) print("DEFENSE: " + COLOR_CYAN + COLOR_STYLE_BRIGHT + str(item[which_item]["defend"]) + COLOR_RESET_ALL) - print("CRITICAL HIT CHANCE: " + COLOR_MAGENTA + COLOR_STYLE_BRIGHT + str(item[which_item]["critical hit chance"]) + COLOR_RESET_ALL) + print( + "CRITICAL HIT CHANCE: " + COLOR_MAGENTA + COLOR_STYLE_BRIGHT + + str(item[which_item]["critical hit chance"]) + COLOR_RESET_ALL + ) if item[which_item]["type"] == "Consumable" or item[which_item]["type"] == "Food": - print("HEALTH BONUS: " + COLOR_STYLE_BRIGHT + COLOR_YELLOW + str(item[which_item]["max bonus"]) + COLOR_RESET_ALL) - print("HEALING: " + COLOR_STYLE_BRIGHT + COLOR_MAGENTA + str(item[which_item]["healing level"]) + COLOR_RESET_ALL) + print( + "HEALTH BONUS: " + COLOR_STYLE_BRIGHT + COLOR_YELLOW + + str(item[which_item]["max bonus"]) + COLOR_RESET_ALL + ) + print( + "HEALING: " + COLOR_STYLE_BRIGHT + COLOR_MAGENTA + + str(item[which_item]["healing level"]) + COLOR_RESET_ALL + ) text = '=' text_handling.print_separator(text) - if str(item[which_item]["type"]) == 'Armor Piece: Chestplate' or str(item[which_item]["type"]) == 'Weapon' or str(item[which_item]["type"]) == 'Armor Piece: Leggings' or str(item[which_item]["type"]) == 'Armor Piece: Boots' or str(item[which_item]["type"]) == 'Armor Piece: Shield': + if str( + item[which_item]["type"] + ) == 'Armor Piece: Chestplate' or str( + item[which_item]["type"] + ) == 'Weapon' or str( + item[which_item]["type"] + ) == 'Armor Piece: Leggings' or str( + item[which_item]["type"] + ) == 'Armor Piece: Boots' or str( + item[which_item]["type"] + ) == 'Armor Piece: Shield': options = ['Equip', 'Get Rid', 'Exit'] elif str(item[which_item]["type"]) == 'Consumable' or str(item[which_item]["type"]) == 'Food': options = ['Consume', 'Get Rid', 'Exit'] @@ -1688,19 +2079,30 @@ def run(play): else: healing_level = item[which_item]["healing level"] health_bonus = item[which_item]["max bonus"] - logger_sys.log_message(f"INFO: Consuming item '{which_item}' --> restoring {healing_level} hp and adding {health_bonus} to player max health as a bonus") + logger_sys.log_message( + f"INFO: Consuming item '{which_item}' --> restoring { + healing_level + } hp and adding {health_bonus} to player max health as a bonus" + ) player["health"] += item[which_item]["healing level"] player["max health"] += item[which_item]["max bonus"] player["inventory"].remove(which_item) elif choice == 'Get Rid': - text = "You won't be able to get this item back if your throw it away. Are you sure you want to throw away this item" + text = ( + "You won't be able to get this item back if your " + + "throw it away. Are you sure you want to throw away this item" + ) text_handling.print_long_string(text) ask = input("? (y/n) ") if ask.lower().startswith('y'): logger_sys.log_message(f"INFO: Getting rid of item '{which_item}'") if item[which_item]["type"] == "Bag": - if ( player["inventory slots remaining"] - item[which_item]["inventory slots"] ) < 0: - text = COLOR_YELLOW + "You cannot throw that item because it would cause your remaining inventory slots to be negative" + COLOR_RESET_ALL + if (player["inventory slots remaining"] - item[which_item]["inventory slots"]) < 0: + text = ( + COLOR_YELLOW + + "You cannot throw that item because it would " + + "cause your remaining inventory slots to be negative" + COLOR_RESET_ALL + ) text_handling.print_long_string(text) time.sleep(1.5) print(" ") @@ -1754,7 +2156,11 @@ def run(play): if "current mount" in player: current_mount_uuid = str(player["current mount"]) if current_mount_uuid != ' ': - print("RIDDED MOUNT: " + COLOR_GREEN + COLOR_STYLE_BRIGHT + player["mounts"][current_mount_uuid]["name"] + COLOR_RESET_ALL + " (" + player["mounts"][current_mount_uuid]["mount"] + ")") + print( + "RIDDED MOUNT: " + COLOR_GREEN + COLOR_STYLE_BRIGHT + + player["mounts"][current_mount_uuid]["name"] + COLOR_RESET_ALL + + " (" + player["mounts"][current_mount_uuid]["mount"] + ")" + ) else: print("RIDDED MOUNT: " + COLOR_RED + COLOR_STYLE_BRIGHT + "NONE" + COLOR_RESET_ALL) mounts_names_list = [] @@ -1804,17 +2210,35 @@ def run(play): print("PLURAL: " + mounts[which_mount_data["mount"]]["plural"]) print(" ") - which_mount_location = "(" + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(map[which_mount_data["location"]]["x"]) + COLOR_RESET_ALL + ", " + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(map[which_mount_data["location"]]["y"]) + COLOR_RESET_ALL + ")" + which_mount_location = ( + "(" + COLOR_GREEN + COLOR_STYLE_BRIGHT + + str(map[which_mount_data["location"]]["x"]) + COLOR_RESET_ALL + + ", " + COLOR_GREEN + COLOR_STYLE_BRIGHT + + str(map[which_mount_data["location"]]["y"]) + COLOR_RESET_ALL + ")" + ) print("LOCATION: " + which_mount_location) - if which_mount_data["is deposited"] == True: + if which_mount_data["is deposited"]: print("STABLE: " + str(map[which_mount_data["location"]]["map zone"])) - print("DEPOSITED DAY: " + COLOR_MAGENTA + COLOR_STYLE_BRIGHT + str(which_mount_data["deposited day"]) + COLOR_RESET_ALL) + print( + "DEPOSITED DAY: " + COLOR_MAGENTA + COLOR_STYLE_BRIGHT + + str(which_mount_data["deposited day"]) + COLOR_RESET_ALL + ) print(" ") print("STATS:") - print(" LEVEL: " + COLOR_GREEN + COLOR_STYLE_BRIGHT + str(int(round(which_mount_data["level"], 0))) + COLOR_RESET_ALL + "/" + str(int(round(mounts[str(which_mount_data["mount"])]["levels"]["max level"])))) - print(" AGILITY ADDITION: " + COLOR_MAGENTA + COLOR_STYLE_BRIGHT + str(which_mount_data["stats"]["agility addition"]) + COLOR_RESET_ALL) - print(" RESISTANCE ADDITION: " + COLOR_CYAN + COLOR_STYLE_BRIGHT + str(which_mount_data["stats"]["resistance addition"]) + COLOR_RESET_ALL) + print( + " LEVEL: " + COLOR_GREEN + COLOR_STYLE_BRIGHT + + str(int(round(which_mount_data["level"], 0))) + COLOR_RESET_ALL + + "/" + str(int(round(mounts[str(which_mount_data["mount"])]["levels"]["max level"]))) + ) + print( + " AGILITY ADDITION: " + COLOR_MAGENTA + COLOR_STYLE_BRIGHT + + str(which_mount_data["stats"]["agility addition"]) + COLOR_RESET_ALL + ) + print( + " RESISTANCE ADDITION: " + COLOR_CYAN + COLOR_STYLE_BRIGHT + + str(which_mount_data["stats"]["resistance addition"]) + COLOR_RESET_ALL + ) print(" ") # get player possible feeding items @@ -1838,7 +2262,7 @@ def run(play): logger_sys.log_message(f"INFO: Player has chosen option '{choice}'") count = 0 continue_action = True - while count < len(list(player["mounts"])) and continue_action == True: + while count < len(list(player["mounts"])) and continue_action: selected_mount_uuid = str(list(player["mounts"])[count]) if player["mounts"][selected_mount_uuid]["name"] == str(which_mount): mount_uuid = selected_mount_uuid @@ -1862,7 +2286,11 @@ def run(play): else: player["mounts"][mount_uuid]["name"] = str(new_name) else: - logger_sys.log_message(f"INFO: Canceling mount examining process --> doesn't own any mount named '{which_mount}'") + logger_sys.log_message( + f"INFO: Canceling mount examining process --> doesn't own any mount named '{ + which_mount + }'" + ) print(COLOR_YELLOW + "You don't have any mounts named like that." + COLOR_RESET_ALL) time.sleep(1.5) else: @@ -1896,13 +2324,14 @@ def run(play): elapsed_time = round(elapsed_time, 2) logger_sys.log_message(f"INFO: Getting elapsed time: '{elapsed_time}'") - game_elapsed_time = .001389 * elapsed_time # 180 seconds irl = .25 days in-game + game_elapsed_time = .001389 * elapsed_time # 180 seconds irl = .25 days in-game game_elapsed_time = round(game_elapsed_time, 2) logger_sys.log_message(f"INFO: Getting elapsed time in game days: '{game_elapsed_time}'") player["elapsed time seconds"] = float(elapsed_time) + float(player["elapsed time seconds"]) player["elapsed time game days"] = game_elapsed_time + player["elapsed time game days"] + if play == 1: play = run(1) @@ -1931,4 +2360,3 @@ def run(play): # deinitialize colorame deinit() os.system('clear') - diff --git a/source/map_item.py b/source/map_item.py index 1d117e4..f17ba5f 100644 --- a/source/map_item.py +++ b/source/map_item.py @@ -37,7 +37,7 @@ def print_map(player, map, zone): get_zone = True try: current_point = search_point(coord_x, coord_y, map_points_num, map) - except: + except Exception: get_zone = False if get_zone and current_point not in current_point_list: print_color = get_zone_color(zone[map["point" + str(current_point)]["map zone"]]["type"]) @@ -53,6 +53,7 @@ def print_map(player, map, zone): count += 1 print("╝") + def get_zone_color(zone_type): program_dir = str(appdirs.user_config_dir(appname='Bane-Of-Wargs')) global zone_color @@ -127,6 +128,7 @@ def get_zone_color(zone_type): text_handling.exit_game() return zone_color + # function to search through the map file def search_point(x, y, map_points_num, map): global map_location diff --git a/source/mission_handling.py b/source/mission_handling.py index e869395..f8178f5 100644 --- a/source/mission_handling.py +++ b/source/mission_handling.py @@ -11,6 +11,7 @@ # initialize colorama init() + # Functions to handle missions def get_mission_id_from_name(mission_name, mission_data): logger_sys.log_message(f"INFO: Getting mission name '{mission_name}' corresponding id") @@ -18,7 +19,7 @@ def get_mission_id_from_name(mission_name, mission_data): count = 0 continue_action = True - while count < len(list(mission_data)) and continue_action == True: + while count < len(list(mission_data)) and continue_action: current_mission_data = mission_data[str(list(mission_data)[count])] if current_mission_data["name"] == mission_name: continue_action = False @@ -28,6 +29,7 @@ def get_mission_id_from_name(mission_name, mission_data): logger_sys.log_message(f"INFO: Found corresponding id of mission name '{mission_name}': {mission_id}") return mission_id + def print_description(mission_data, map): logger_sys.log_message(f"INFO: Printing mission '{mission_data}' description to GUI") @@ -53,7 +55,10 @@ def print_description(mission_data, map): count = 0 while count < len(stopovers_for_mission): current_map_point_data = map["point" + str(stopovers_for_mission[count])] - current_map_point_coordinates = "[X:" + str(current_map_point_data["x"]) + ", Y:" + str(current_map_point_data["y"]) + "]" + current_map_point_coordinates = ( + "[X:" + str(current_map_point_data["x"]) + ", Y:" + + str(current_map_point_data["y"]) + "]" + ) new_stopovers_for_mission.append(current_map_point_coordinates) count += 1 @@ -70,7 +75,6 @@ def print_description(mission_data, map): } logger_sys.log_message(f"INFO: Loading missions text replacements: '{mission_text_replacements}'") - text = str(mission_data["description"]) # Replace text replacement in the description by # its corresponding value in the mission_text_replacements @@ -93,6 +97,7 @@ def print_description(mission_data, map): new_input = new_input[1:] print(str(new_input)) + def mission_checks(mission_data, player, which_key): global checks_passed # Get every checks required @@ -104,7 +109,13 @@ def mission_checks(mission_data, player, which_key): # If which_key input is invalid, quit # the game and output the error to the # game logs files - if which_key != 'to offer' and which_key != 'to complete' and which_key != 'to fail' and which_key != 'to spawn' and which_key != 'to despawn': + if ( + which_key != 'to offer' + and which_key != 'to complete' + and which_key != 'to fail' + and which_key != 'to spawn' + and which_key != 'to despawn' + ): logger_sys.log_message(f"ERROR: Stopping mission checks for mission data '{mission_data}' --> invalid key '{which_key}'") text_handling.exit_game() @@ -129,7 +140,7 @@ def mission_checks(mission_data, player, which_key): # Player attributes checks if 'Player Attributes' in checks: - while count < len(mission_data[which_key]["player attributes"]) and checks_passed == True: + while count < len(mission_data[which_key]["player attributes"]) and checks_passed: current_attribute = mission_data[which_key]["player attributes"][count] if str(current_attribute) not in player["attributes"]: checks_passed = False @@ -139,7 +150,7 @@ def mission_checks(mission_data, player, which_key): # Visited locations checks if 'Visited Locations' in checks: - while count < len(mission_data[which_key]["visited locations"]) and checks_passed == True: + while count < len(mission_data[which_key]["visited locations"]) and checks_passed: current_location = mission_data[which_key]["visited locations"][count] if current_location not in player["visited points"]: checks_passed = False @@ -149,7 +160,7 @@ def mission_checks(mission_data, player, which_key): # Known enemies checks if 'Known Enemies' in checks: - while count < len(mission_data[which_key]["known enemies"]) and checks_passed == True: + while count < len(mission_data[which_key]["known enemies"]) and checks_passed: current_enemy = mission_data[which_key]["known enemies"][count] if current_enemy not in player["enemies list"]: checks_passed = False @@ -159,7 +170,7 @@ def mission_checks(mission_data, player, which_key): # Known zones checks if 'Known Zones' in checks: - while count < len(mission_data[which_key]["known zones"]) and checks_passed == True: + while count < len(mission_data[which_key]["known zones"]) and checks_passed: current_enemy = mission_data[which_key]["known zones"][count] if current_enemy not in player["visited zones"]: checks_passed = False @@ -169,7 +180,7 @@ def mission_checks(mission_data, player, which_key): # Known npcs checks if 'Known Npcs' in checks: - while count < len(mission_data[which_key]["known npcs"]) and checks_passed == True: + while count < len(mission_data[which_key]["known npcs"]) and checks_passed: current_enemy = mission_data[which_key]["known npcs"][count] if current_enemy not in player["met npcs names"]: checks_passed = False @@ -179,7 +190,7 @@ def mission_checks(mission_data, player, which_key): # Has items checks if 'Has Items' in checks: - while count < len(mission_data[which_key]["has items"]) and checks_passed == True: + while count < len(mission_data[which_key]["has items"]) and checks_passed: current_item = mission_data[which_key]["has items"][count] if which_key == 'to fail': @@ -194,17 +205,25 @@ def mission_checks(mission_data, player, which_key): return checks_passed + def execute_triggers(mission_data, player, which_key, dialog, preferences, text_replacements_generic, drinks): # If which_key input is invalid, quit # the game and output the error to the # game logs files - if which_key != 'on offer' and which_key != 'on complete' and which_key != 'on fail': + if ( + which_key != 'on offer' + and which_key != 'on complete' + and which_key != 'on fail' + ): logger_sys.log_message(f"ERROR: Stopping mission checks for mission data '{mission_data}' --> invalid key '{which_key}'") text_handling.exit_game() if which_key in mission_data: if "dialog" in mission_data[which_key]: - dialog_handling.print_dialog(mission_data[which_key]["dialog"], dialog, preferences, text_replacements_generic, player, drinks) + dialog_handling.print_dialog( + mission_data[which_key]["dialog"], dialog, preferences, + text_replacements_generic, player, drinks + ) if "payment" in mission_data[which_key]: player["gold"] += int(mission_data[which_key]["payment"]) if "fine" in mission_data[which_key]: @@ -212,6 +231,7 @@ def execute_triggers(mission_data, player, which_key, dialog, preferences, text_ if "exp addition" in mission_data[which_key]: player["exp"] += int(mission_data[which_key]["exp addition"]) + def offer_mission(mission_id, player, missions_data, dialog, preferences, text_replacements_generic, drinks): logger_sys.log_message(f"INFO: Offering mission '{mission_id}' to player") data = missions_data[mission_id] @@ -226,7 +246,7 @@ def offer_mission(mission_id, player, missions_data, dialog, preferences, text_r else: can_offer = True - if can_offer == True: + if can_offer: player["offered missions"].append(mission_id) mission_dict = { @@ -244,15 +264,17 @@ def offer_mission(mission_id, player, missions_data, dialog, preferences, text_r # Only ask for accepting mission if there is a dialog, # else, make the player automatically accept it if "dialog" in list(data["on offer"]): - dialog_handling.print_dialog(data["on offer"]["dialog"], dialog, preferences, text_replacements_generic, player, drinks) + dialog_handling.print_dialog( + data["on offer"]["dialog"], dialog, preferences, text_replacements_generic, player, drinks + ) accept = input("Do you want to accept this task? (y/n)") print("=======================================================") if accept.startswith('y'): - if player["active missions"] == None: + if player["active missions"] is None: player["active missions"] = [] player["active missions"].append(mission_id) else: - if player["active missions"] == None: + if player["active missions"] is None: player["active missions"] = [] player["active missions"] += [mission_id] if "payment" in list(data["on offer"]): @@ -262,11 +284,12 @@ def offer_mission(mission_id, player, missions_data, dialog, preferences, text_r if "exp addition" in list(data["on offer"]): player["exp"] += int(data["on offer"]["exp addition"]) else: - if player["active missions"] == None: + if player["active missions"] is None: player["active missions"] = [] player["active missions"].append(mission_id) logger_sys.log_message(f"INFO: Finished triggering mission '{mission_id}' 'on offer' triggers") + def mission_completing_checks(mission_id, missions_data, player, dialog, preferences, text_replacements_generic, drinks): # Load mission data and check if the # required attributes to complete the @@ -289,18 +312,16 @@ def mission_completing_checks(mission_id, missions_data, player, dialog, prefere # remove the mission id from the player # 'active missions' list and add it to the # 'done missions' list - if attributes_checks_passed == True and stopovers_checks_passed == True: + if attributes_checks_passed and stopovers_checks_passed: logger_sys.log_message(f"INFO: Executing mission '{mission_id}' completing triggers") execute_triggers(mission_data, player, 'on complete', dialog, preferences, text_replacements_generic, drinks) logger_sys.log_message(f"INFO: Set mission '{mission_id}' as done") - print(COLOR_CYAN + COLOR_STYLE_BRIGHT + "You completed mission '" + current_mission_data["name"] + "'" + COLOR_RESET_ALL) + print(COLOR_CYAN + COLOR_STYLE_BRIGHT + "You completed mission '" + mission_data["name"] + "'" + COLOR_RESET_ALL) player["active missions"].remove(mission_id) player["done missions"].append(mission_id) - - # deinitialize colorama deinit() diff --git a/source/npc_handling.py b/source/npc_handling.py index 9eeed7e..a249db0 100644 --- a/source/npc_handling.py +++ b/source/npc_handling.py @@ -11,6 +11,7 @@ # initialize colorama init() + # Handling functions def init_npc(map_location, player, npcs, drinks, item, preferences, map): current_npc = str(map["point" + str(map_location)]["npc"]) @@ -46,7 +47,12 @@ def init_npc(map_location, player, npcs, drinks, item, preferences, map): npc_drinks_len = len(npc_drinks) while count < npc_drinks_len: current_drink = str(npcs[current_npc]["sells"]["drinks"][int(count)]) - print(" -" + npcs[current_npc]["sells"]["drinks"][int(count)] + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(drinks[current_drink]["gold"] * npcs[current_npc]["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + npcs[current_npc]["sells"]["drinks"][int(count)] + " " + + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(round(drinks[current_drink]["gold"] * npcs[current_npc]["cost value"], 2)) + + COLOR_RESET_ALL + ) count += 1 options += ['Buy Drink'] if "None" not in npcs[current_npc]["sells"]["items"]: @@ -56,7 +62,11 @@ def init_npc(map_location, player, npcs, drinks, item, preferences, map): npc_items_len = len(npc_items) while count < npc_items_len: current_item = str(npcs[current_npc]["sells"]["items"][int(count)]) - print(" -" + npcs[current_npc]["sells"]["items"][int(count)] + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(item[current_item]["gold"] * npcs[current_npc]["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + npcs[current_npc]["sells"]["items"][int(count)] + " " + COLOR_YELLOW + + COLOR_STYLE_BRIGHT + str(round(item[current_item]["gold"] * npcs[current_npc]["cost value"], 2)) + + COLOR_RESET_ALL + ) count += 1 options += ['Buy Item'] if "None" not in npcs[current_npc]["buys"]["items"]: @@ -66,7 +76,11 @@ def init_npc(map_location, player, npcs, drinks, item, preferences, map): npc_items_len = len(npc_items) while count < npc_items_len: current_item = str(npcs[current_npc]["buys"]["items"][int(count)]) - print(" -" + npcs[current_npc]["buys"]["items"][int(count)] + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(item[current_item]["gold"] * npcs[current_npc]["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + npcs[current_npc]["buys"]["items"][int(count)] + " " + COLOR_YELLOW + + COLOR_STYLE_BRIGHT + str(round(item[current_item]["gold"] * npcs[current_npc]["cost value"], 2)) + + COLOR_RESET_ALL + ) count += 1 options += ['Sell Item'] options += ['Exit'] @@ -78,34 +92,63 @@ def init_npc(map_location, player, npcs, drinks, item, preferences, map): choice = term_menu.show_menu(options) if choice == 'Buy Drink': which_drink = input("Which drink do you want to buy from him? ") - if which_drink in npcs[current_npc]["sells"]["drinks"] and ( drinks[which_drink]["gold"] * npcs[current_npc]["cost value"] ) < player["gold"]: - logger_sys.log_message(f"INFO: Player bought drink '{which_drink}' from npc '{current_npc}', causing the player to loose " + str( drinks[which_drink]["gold"] * npcs[current_npc]["cost value"] ) + " gold") + if ( + which_drink in npcs[current_npc]["sells"]["drinks"] + and (drinks[which_drink]["gold"] * npcs[current_npc]["cost value"]) < player["gold"] + ): + logger_sys.log_message( + f"INFO: Player bought drink '{which_drink}' from npc '{current_npc}', causing the player to loose " + + str(drinks[which_drink]["gold"] * npcs[current_npc]["cost value"]) + " gold" + ) player["gold"] -= drinks[which_drink]["gold"] * npcs[current_npc]["cost value"] if drinks[which_drink]["healing level"] == 999: player["health"] = player["max health"] else: player["health"] += drinks[which_drink]["healing level"] else: - text = COLOR_YELLOW + "You cannot buy that items because it would cause your gold to be negative." + COLOR_RESET_ALL + text = ( + COLOR_YELLOW + "You cannot buy that items because it would cause your gold to be negative." + + COLOR_RESET_ALL + ) text_handling.print_long_string(text) elif choice == 'Buy Item': which_item = input("Which item do you want to buy from him? ") - if which_item in npcs[current_npc]["sells"]["items"] and ( item[which_item]["gold"] * npcs[current_npc]["cost value"] ) < player["gold"]: + if ( + which_item in npcs[current_npc]["sells"]["items"] + and (item[which_item]["gold"] * npcs[current_npc]["cost value"]) < player["gold"] + ): if player["inventory slots remaining"] > 0: - logger_sys.log_message("INFO: Player bought item '{which_item}' from npc '{current_npc}', causing him, to loose " + str( item[which_item]["gold"] * npcs[current_npc]["cost value"] ) + " gold") + logger_sys.log_message( + f"INFO: Player bought item '{which_item}' from npc '{current_npc}', causing him, to loose " + str( + item[which_item]["gold"] * npcs[current_npc]["cost value"] + ) + " gold" + ) player["inventory slots remaining"] -= 1 player["inventory"].append(which_item) player["gold"] -= item[which_item]["gold"] * npcs[current_npc]["cost value"] else: - text = COLOR_YELLOW + "You cannot buy that items because it would cause your inventory slots to be negative." + COLOR_RESET_ALL + text = ( + COLOR_YELLOW + "You cannot buy that items because it would cause your inventory slots to be negative." + + COLOR_RESET_ALL + ) text_handling.print_long_string(text) else: - text = COLOR_YELLOW + "You cannot buy that items because it would cause your gold to be negative." + COLOR_RESET_ALL + text = ( + COLOR_YELLOW + "You cannot buy that items because it would cause your gold to be negative." + + COLOR_RESET_ALL + ) text_handling.print_long_string(text) elif choice == 'Sell Item': which_item = input("Which item do you want to sell him? ") - if which_item in npcs[current_npc]["buys"]["items"] and ( item[which_item]["gold"] * npcs[current_npc]["cost value"] ) < player["gold"] and which_item in player["inventory"]: - logger_sys.log_message("INFO: Player has sold item '{witch_item}' to npc '{current_npc}' for " + str( item[which_item]["gold"] * npcs[current_npc]["cost value"] ) + " gold") + if ( + which_item in npcs[current_npc]["buys"]["items"] + and (item[which_item]["gold"] * npcs[current_npc]["cost value"]) < player["gold"] + and which_item in player["inventory"] + ): + logger_sys.log_message( + "INFO: Player has sold item '{witch_item}' to npc '{current_npc}' for " + + str(item[which_item]["gold"] * npcs[current_npc]["cost value"]) + " gold" + ) player["inventory slots remaining"] -= 1 player["gold"] += item[which_item]["gold"] * npcs[current_npc]["cost value"] player["inventory"].remove(which_item) @@ -133,12 +176,14 @@ def init_npc(map_location, player, npcs, drinks, item, preferences, map): if which_item == player["held shield"]: player["held shield"] = " " else: - text = COLOR_YELLOW + "You cannot buy that items because it would cause your gold to be negative or because you don't own that item." + COLOR_RESET_ALL + text = ( + COLOR_YELLOW + "You cannot buy that items because it would cause " + + "your gold to be negative or because you don't own that item." + COLOR_RESET_ALL + ) text_handling.print_long_string(text) else: p = False - # deinitialize colorama deinit() diff --git a/source/term_menu.py b/source/term_menu.py index 1f696ad..7424c88 100644 --- a/source/term_menu.py +++ b/source/term_menu.py @@ -1,9 +1,12 @@ from simple_term_menu import TerminalMenu -def show_menu(options): +def show_menu(options): # settings for the single-choice menu - terminal_menu = TerminalMenu(options, menu_cursor_style=("fg_green", "bold"), menu_highlight_style=("fg_green", "bold")) + terminal_menu = TerminalMenu( + options, menu_cursor_style=("fg_green", "bold"), + menu_highlight_style=("fg_green", "bold") + ) # show to menu and stores the user input to choice menu_entry_index = terminal_menu.show() diff --git a/source/text_handling.py b/source/text_handling.py index 3009ada..ca00b19 100644 --- a/source/text_handling.py +++ b/source/text_handling.py @@ -15,6 +15,7 @@ # Handling functions program_dir = str(appdirs.user_config_dir(appname='Bane-Of-Wargs')) + def print_speech_text_effect(text, preferences): text = str(text) + "\n" new_input = "" @@ -22,7 +23,7 @@ def print_speech_text_effect(text, preferences): if i % 54 == 0: new_input += '\n' new_input += letter - if preferences["speed up"] == False: + if not preferences["speed up"]: for character in new_input: sys.stdout.write(character) sys.stdout.flush() @@ -33,6 +34,7 @@ def print_speech_text_effect(text, preferences): sys.stdout.flush() time.sleep(.02) + def exit_game(): time.sleep(1.5) print(COLOR_YELLOW + "Warning: closing game now" + COLOR_RESET_ALL) @@ -41,6 +43,7 @@ def exit_game(): os.system('clear') exit(1) + def print_separator(character): count = 0 @@ -50,12 +53,14 @@ def print_separator(character): count += 1 sys.stdout.write('\n') + def overstrike_text(text): result = "" for character in text: result = result + character + '\u0336' print(str(result)) + def print_long_string(text): new_input = "" for i, letter in enumerate(text): @@ -67,6 +72,7 @@ def print_long_string(text): new_input = new_input[1:] print(str(new_input)) + def print_zone_map(zone_name, zone, player, preferences): logger_sys.log_message(f"INFO: Printing zone map '{zone_name}' ascii art") to_print = zone[zone_name]["map"]["map full"] @@ -102,17 +108,29 @@ def print_zone_map(zone_name, zone, player, preferences): if count == 0: print(line + " NAME: " + preferences["latest preset"]["save"]) if count == 1: - print(line + " HEALTH: " + COLOR_STYLE_BRIGHT + COLOR_BLUE + str(player["health"]) + COLOR_RESET_ALL + "/" + COLOR_STYLE_BRIGHT + COLOR_BLUE+ str(player["max health"]) + COLOR_RESET_ALL) + print( + line + " HEALTH: " + COLOR_STYLE_BRIGHT + COLOR_BLUE + + str(player["health"]) + COLOR_RESET_ALL + "/" + COLOR_STYLE_BRIGHT + + COLOR_BLUE + str(player["max health"]) + COLOR_RESET_ALL + ) if count == 2: - print(line + " INVENTORY: " + COLOR_STYLE_BRIGHT + COLOR_CYAN + str(len(player["inventory"]) + 1) + COLOR_RESET_ALL + "/" + COLOR_STYLE_BRIGHT + COLOR_CYAN + str(player["inventory slots"]) + COLOR_RESET_ALL) + print( + line + " INVENTORY: " + COLOR_STYLE_BRIGHT + COLOR_CYAN + + str(len(player["inventory"]) + 1) + COLOR_RESET_ALL + "/" + + COLOR_STYLE_BRIGHT + COLOR_CYAN + str(player["inventory slots"]) + COLOR_RESET_ALL + ) if count == 3: - print(line + " ELAPSED DAYS: " + COLOR_STYLE_BRIGHT + COLOR_MAGENTA + str(round(player["elapsed time game days"], 1)) + COLOR_RESET_ALL) + print( + line + " ELAPSED DAYS: " + COLOR_STYLE_BRIGHT + COLOR_MAGENTA + + str(round(player["elapsed time game days"], 1)) + COLOR_RESET_ALL + ) if count == 4: print(line + " EXP: " + COLOR_STYLE_BRIGHT + COLOR_GREEN + str(round(player["xp"], 2)) + COLOR_RESET_ALL) if count == 5: print(line + " GOLD: " + COLOR_STYLE_BRIGHT + COLOR_YELLOW + str(round(player["gold"], 2)) + COLOR_RESET_ALL) count += 1 + def print_zone_map_alone(zone_name, zone): logger_sys.log_message(f"INFO: Printing zone map '{zone_name}' ascii art") to_print = zone[zone_name]["map"]["map full"] @@ -132,13 +150,17 @@ def print_zone_map_alone(zone_name, zone): print(line) count += 1 + def print_npc_thumbnail(npc, preferences): logger_sys.log_message(f"INFO: Printing NPC '{npc}' thumbnail") if preferences["latest preset"]["type"] == "vanilla": with open(program_dir + '/game/imgs/' + npc + ".txt") as f: to_print = str(f.read()) else: - with open(program_dir + '/plugins/' + str(preferences["latest preset"]["plugin"]) + '/imgs/' + npc + ".txt") as f: + with open( + program_dir + '/plugins/' + str(preferences["latest preset"]["plugin"]) + + '/imgs/' + npc + ".txt" + ) as f: to_print = str(f.read()) to_print = to_print.replace('$RED', '\033[0;31m') to_print = to_print.replace('$GREEN', '\033[0;32m') @@ -156,13 +178,17 @@ def print_npc_thumbnail(npc, preferences): print(line) count += 1 + def print_enemy_thumbnail(enemy, preferences): logger_sys.log_message(f"INFO: Printing enemy '{enemy}' thumbnail") if preferences["latest preset"]["type"] == "vanilla": with open(program_dir + '/game/imgs/' + enemy + ".txt") as f: to_print = str(f.read()) else: - with open(program_dir + '/plugins/' + str(preferences["latest preset"]["plugin"]) + '/imgs/' + enemy + ".txt") as f: + with open( + program_dir + '/plugins/' + str(preferences["latest preset"]["plugin"]) + + '/imgs/' + enemy + ".txt" + ) as f: to_print = str(f.read()) to_print = to_print.replace('$RED', '\033[0;31m') to_print = to_print.replace('$GREEN', '\033[0;32m') @@ -180,6 +206,7 @@ def print_enemy_thumbnail(enemy, preferences): print(line) count += 1 + def a_an_check(word): logger_sys.log_message(f"INFO: Checking correct grammar of 'a' in front of '{word}'") global to_return diff --git a/source/train.py b/source/train.py index f4c70f8..a088e31 100644 --- a/source/train.py +++ b/source/train.py @@ -11,6 +11,7 @@ # initialize colorama init() + def training_loop(mount_uuid, player, item, mounts, stable): still_training = True current_mount_type = str(player["mounts"][str(mount_uuid)]["mount"]) @@ -45,7 +46,9 @@ def training_loop(mount_uuid, player, item, mounts, stable): player["inventory"].remove(which_food) player["xp"] += random.randint(1, 4) if player["current mount"] in player["mounts"]: - player["mounts"][player["current mount"]]["level"] += round(random.uniform(.02, .10), 3) / mounts[current_mount_type]["feed"]["feed needs"] + player["mounts"][player["current mount"]]["level"] += round( + random.uniform(.02, .10), 3 + ) / mounts[current_mount_type]["feed"]["feed needs"] else: text = COLOR_YELLOW + "You cannot feed your mount with this food or you don't own that food." + COLOR_RESET_ALL text_handling.print_long_string(text) @@ -82,7 +85,7 @@ def training_loop(mount_uuid, player, item, mounts, stable): # calculate elapsed time elapsed_time = end_time - start_time elapsed_time = round(elapsed_time, 2) - game_elapsed_time = .001389 * elapsed_time # 180 seconds irl = .25 days in-game + game_elapsed_time = .001389 * elapsed_time # 180 seconds irl = .25 days in-game game_elapsed_time = round(game_elapsed_time, 2) player["gold"] -= stable["training gold"] * game_elapsed_time else: diff --git a/source/uuid_handling.py b/source/uuid_handling.py index c78a880..28bd2de 100644 --- a/source/uuid_handling.py +++ b/source/uuid_handling.py @@ -1,6 +1,7 @@ import logger_sys import uuid + # Handling functions def generate_random_uuid(): logger_sys.log_message("INFO: Generating new random UUID using 'uuid.4' method") diff --git a/source/weapon_upgrade_handling.py b/source/weapon_upgrade_handling.py index 10638fe..3b730dc 100644 --- a/source/weapon_upgrade_handling.py +++ b/source/weapon_upgrade_handling.py @@ -1,5 +1,6 @@ import logger_sys + # Handling functions def check_for_item(item_name, item): logger_sys.log_message(f"INFO: Checking if item '{item_name}' actually exists") @@ -8,6 +9,7 @@ def check_for_item(item_name, item): item_exist = True return item_exist + def check_weapon_next_upgrade_name(item_name, item): logger_sys.log_message(f"INFO: Check for equipment '{item_name}' next upgrade") weapon_next_upgrade_name = str(item_name) @@ -27,7 +29,9 @@ def check_weapon_next_upgrade_name(item_name, item): if not weapon_already_upgraded: weapon_next_upgrade_name = str(item_name) + " (1)" else: - weapon_next_upgrade_name = str(weapon_next_upgrade_name[ 0 : weapon_next_upgrade_name.index("(")]) + "(" + str(item_data["upgrade tier"] + 1) + ")" + weapon_next_upgrade_name = str( + weapon_next_upgrade_name[0: weapon_next_upgrade_name.index("(")] + ) + "(" + str(item_data["upgrade tier"] + 1) + ")" # check if the next upgrade actually exist item_upgrade_exist = check_for_item(weapon_next_upgrade_name, item) @@ -39,6 +43,7 @@ def check_weapon_next_upgrade_name(item_name, item): return weapon_next_upgrade_name + def check_weapon_max_upgrade(item_name, item): logger_sys.log_message(f"INFO: Getting equipment '{item_name}' max upgrade") weapon_next_upgrade_name = str(item_name) @@ -52,14 +57,16 @@ def check_weapon_max_upgrade(item_name, item): if "(" in str(weapon_next_upgrade_name): weapon_already_upgraded = True - if weapon_already_upgraded == False: + if not weapon_already_upgraded: weapon_next_upgrade_name = str(item_name) + " (1)" else: - weapon_next_upgrade_name = str(weapon_next_upgrade_name[ 0 : weapon_next_upgrade_name.index("(")]) + "(" + str(item_data["upgrade tier"] + 1) + ")" + weapon_next_upgrade_name = str( + weapon_next_upgrade_name[0: weapon_next_upgrade_name.index("(")] + ) + "(" + str(item_data["upgrade tier"] + 1) + ")" # check if the next upgrade actually exist item_upgrade_exist = check_for_item(weapon_next_upgrade_name, item) - if item_upgrade_exist == False: + if not item_upgrade_exist: further_upgrade = False # correct max upgrade count @@ -72,6 +79,7 @@ def check_weapon_max_upgrade(item_name, item): return weapon_next_upgrade_name_count + def detect_weapon_next_upgrade_items(item_name, item): logger_sys.log_message(f"INFO: Getting equipment '{item_name}' next upgrade items") weapon_next_upgrade_name = str(item_name) @@ -85,7 +93,9 @@ def detect_weapon_next_upgrade_items(item_name, item): if not weapon_already_upgraded: weapon_next_upgrade_name = str(item_name) + " (1)" else: - weapon_next_upgrade_name = str(weapon_next_upgrade_name[ 0 : weapon_next_upgrade_name.index("(")]) + "(" + str(item_data["upgrade tier"] + 1) + ")" + weapon_next_upgrade_name = str( + weapon_next_upgrade_name[0: weapon_next_upgrade_name.index("(")] + ) + "(" + str(item_data["upgrade tier"] + 1) + ")" # check if the next upgrade actually exist item_upgrade_exist = check_for_item(weapon_next_upgrade_name, item) @@ -93,7 +103,7 @@ def detect_weapon_next_upgrade_items(item_name, item): weapon_next_upgrade_name = None # get next weapon upgrade needed items - if weapon_next_upgrade_name != None: + if weapon_next_upgrade_name is not None: weapon_next_upgrade_items = item[str(weapon_next_upgrade_name)]["for this upgrade"] else: weapon_next_upgrade_items = "None" @@ -109,7 +119,11 @@ def detect_weapon_next_upgrade_items(item_name, item): while count2 < current_item_number - 1: weapon_next_upgrade_items.remove(current_item) count2 += 1 - weapon_next_upgrade_items = [sub.replace(current_item, current_item + "X" + str(current_item_number)) for sub in weapon_next_upgrade_items] + weapon_next_upgrade_items = [ + sub.replace( + current_item, current_item + "X" + str(current_item_number) + ) for sub in weapon_next_upgrade_items + ] count += 1 diff --git a/source/zone_handling.py b/source/zone_handling.py index 407385a..c3d3068 100644 --- a/source/zone_handling.py +++ b/source/zone_handling.py @@ -15,18 +15,20 @@ # Handling functions + # Information printing functions def print_zone_news(zone, map_zone): logger_sys.log_message(f"INFO: Printing map zone '{map_zone}' news") print("NEWS:") village_news = zone[map_zone]["news"] village_news_len = len(village_news) - choose_rand_news = random.randint(0, ( village_news_len - 1 )) + choose_rand_news = random.randint(0, (village_news_len - 1)) choose_rand_news = village_news[int(choose_rand_news)] text_handling.print_long_string(choose_rand_news) text = '=' text_handling.print_separator(text) + def print_forge_information(map_zone, zone, item): current_forge = zone[map_zone] current_forge_name = current_forge["name"] @@ -42,7 +44,10 @@ def print_forge_information(map_zone, zone, item): metal_buys_len = len(metal_buys) while count < metal_buys_len: current_metal = str(metal_buys[count]) - print(" -" + current_metal + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(item[current_metal]["gold"] * current_forge["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + current_metal + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(round(item[current_metal]["gold"] * current_forge["cost value"], 2)) + COLOR_RESET_ALL + ) count += 1 if "None" not in current_forge["forge"]["sells"]: print("METAL SELLS:") @@ -51,11 +56,15 @@ def print_forge_information(map_zone, zone, item): metal_sells_len = len(metal_sells) while count < metal_sells_len: current_metal = str(metal_sells[count]) - print(" -" + current_metal + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(item[current_metal]["gold"] * current_forge["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + current_metal + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(round(item[current_metal]["gold"] * current_forge["cost value"], 2)) + COLOR_RESET_ALL + ) count += 1 text = '=' text_handling.print_separator(text) + def print_blacksmith_information(map_zone, zone, item): current_black_smith = zone[map_zone] current_black_smith_name = current_black_smith["name"] @@ -71,7 +80,10 @@ def print_blacksmith_information(map_zone, zone, item): weapon_buys_len = len(weapon_buys) while count < weapon_buys_len: current_weapon = str(weapon_buys[int(count)]) - print(" -" + current_weapon + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(item[current_weapon]["gold"] * current_black_smith["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + current_weapon + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(round(item[current_weapon]["gold"] * current_black_smith["cost value"], 2)) + COLOR_RESET_ALL + ) count += 1 if "None" not in current_black_smith["blacksmith"]["orders"]: print("EQUIPMENT ORDERS:") @@ -102,7 +114,11 @@ def print_blacksmith_information(map_zone, zone, item): while count3 < global_current_weapon_materials.count(current_material): global_current_weapon_materials.remove(current_material) count3 += 1 - global_current_weapon_materials = [sub.replace(current_material, current_material + "X" + current_material_number) for sub in global_current_weapon_materials] + global_current_weapon_materials = [ + sub.replace( + current_material, current_material + "X" + current_material_number + ) for sub in global_current_weapon_materials + ] count2 += 1 @@ -110,11 +126,18 @@ def print_blacksmith_information(map_zone, zone, item): global_current_weapon_materials = global_current_weapon_materials.replace("'", '') global_current_weapon_materials = global_current_weapon_materials.replace("[", '') global_current_weapon_materials = global_current_weapon_materials.replace("]", '') - print(" -" + current_weapon + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(item[current_weapon]["gold"] * current_black_smith["cost value"], 2)) + COLOR_RESET_ALL + COLOR_GREEN + COLOR_STYLE_BRIGHT + " (" + COLOR_RESET_ALL + global_current_weapon_materials + COLOR_GREEN + COLOR_STYLE_BRIGHT + ")" + COLOR_RESET_ALL) + print( + " -" + current_weapon + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(round(item[current_weapon]["gold"] * current_black_smith["cost value"], 2)) + + COLOR_RESET_ALL + COLOR_GREEN + COLOR_STYLE_BRIGHT + + " (" + COLOR_RESET_ALL + global_current_weapon_materials + + COLOR_GREEN + COLOR_STYLE_BRIGHT + ")" + COLOR_RESET_ALL + ) count += 1 text = '=' text_handling.print_separator(text) + def print_stable_information(map_zone, zone, mounts, item, player, map_location): current_stable = zone[map_zone] current_stable_name = current_stable["name"] @@ -133,7 +156,11 @@ def print_stable_information(map_zone, zone, mounts, item, player, map_location) stable_mounts_len = len(stable_mounts) while count < stable_mounts_len: current_mount = str(stable_mounts[int(count)]) - print(" -" + current_stable["stable"]["sells"]["mounts"][int(count)] + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(mounts[current_mount]["gold"] * current_stable["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + current_stable["stable"]["sells"]["mounts"][int(count)] + " " + COLOR_YELLOW + + COLOR_STYLE_BRIGHT + str(round(mounts[current_mount]["gold"] * current_stable["cost value"], 2)) + + COLOR_RESET_ALL + ) count += 1 if "None" not in current_stable["stable"]["sells"]["items"]: options += ['Buy Item'] @@ -143,7 +170,11 @@ def print_stable_information(map_zone, zone, mounts, item, player, map_location) stable_items_len = len(stable_items) while count < stable_items_len: current_mount = str(stable_items[int(count)]) - print(" -" + current_stable["stable"]["sells"]["items"][int(count)] + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(item[current_mount]["gold"] * current_stable["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + current_stable["stable"]["sells"]["items"][int(count)] + " " + COLOR_YELLOW + + COLOR_STYLE_BRIGHT + str(round(item[current_mount]["gold"] * current_stable["cost value"], 2)) + + COLOR_RESET_ALL + ) count += 1 print(" ") deposited_mounts_num = 0 @@ -152,12 +183,16 @@ def print_stable_information(map_zone, zone, mounts, item, player, map_location) deposited_mounts_names = [] if "None" not in list(player["mounts"]): while count < mounts_list_len: - selected_mount = list(player["mounts"])[count] - selected_mount = str(selected_mount) - if player["mounts"][selected_mount]["location"] == "point" + str(map_location) and player["mounts"][selected_mount]["is deposited"] == True: - deposited_mounts_num += 1 - deposited_mounts_names += [str(player["mounts"][selected_mount]["name"])] - count += 1 + selected_mount = list(player["mounts"])[count] + selected_mount = str(selected_mount) + if ( + player["mounts"][selected_mount]["location"] == "point" + + str(map_location) + and player["mounts"][selected_mount]["is deposited"] + ): + deposited_mounts_num += 1 + deposited_mounts_names += [str(player["mounts"][selected_mount]["name"])] + count += 1 else: deposited_mounts_names = 0 deposited_mounts_num = 0 @@ -169,10 +204,14 @@ def print_stable_information(map_zone, zone, mounts, item, player, map_location) if deposited_mounts_num == 0: print("MOUNTS DEPOSITED HERE: " + COLOR_BLUE + COLOR_STYLE_BRIGHT + str(deposited_mounts_num) + COLOR_RESET_ALL) else: - print("MOUNTS DEPOSITED HERE: " + COLOR_BLUE + COLOR_STYLE_BRIGHT + str(deposited_mounts_num) + COLOR_RESET_ALL + " " + deposited_mounts_names) + print( + "MOUNTS DEPOSITED HERE: " + COLOR_BLUE + COLOR_STYLE_BRIGHT + + str(deposited_mounts_num) + COLOR_RESET_ALL + " " + deposited_mounts_names + ) text = '=' text_handling.print_separator(text) + def print_hostel_information(map_zone, zone, item, drinks): current_hostel = zone[map_zone] current_hostel_name = current_hostel["name"] @@ -189,7 +228,11 @@ def print_hostel_information(map_zone, zone, item, drinks): hostel_drinks_len = len(hostel_drinks) while count < hostel_drinks_len: current_drink = str(current_hostel["sells"]["drinks"][int(count)]) - print(" -" + current_hostel["sells"]["drinks"][int(count)] + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(drinks[current_drink]["gold"] * current_hostel["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + current_hostel["sells"]["drinks"][int(count)] + " " + COLOR_YELLOW + + COLOR_STYLE_BRIGHT + str(round(drinks[current_drink]["gold"] * current_hostel["cost value"], 2)) + + COLOR_RESET_ALL + ) count += 1 if "None" not in current_hostel["sells"]["items"]: print("ITEMS SELLS") @@ -198,7 +241,11 @@ def print_hostel_information(map_zone, zone, item, drinks): hostel_items_len = len(hostel_items) while count < hostel_items_len: current_item = str(current_hostel["sells"]["items"][int(count)]) - print(" -" + current_hostel["sells"]["items"][int(count)] + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(item[current_item]["gold"] * current_hostel["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + current_hostel["sells"]["items"][int(count)] + " " + COLOR_YELLOW + + COLOR_STYLE_BRIGHT + str(round(item[current_item]["gold"] * current_hostel["cost value"], 2)) + + COLOR_RESET_ALL + ) count += 1 if "None" not in current_hostel["buys"]["items"]: print("ITEMS BUYS:") @@ -207,13 +254,18 @@ def print_hostel_information(map_zone, zone, item, drinks): hostel_items_len = len(hostel_items) while count < hostel_items_len: current_item = str(current_hostel["buys"]["items"][int(count)]) - print(" -" + current_hostel["buys"]["items"][int(count)] + " " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(item[current_item]["gold"] * current_hostel["cost value"], 2)) + COLOR_RESET_ALL) + print( + " -" + current_hostel["buys"]["items"][int(count)] + " " + COLOR_YELLOW + + COLOR_STYLE_BRIGHT + str(round(item[current_item]["gold"] * current_hostel["cost value"], 2)) + + COLOR_RESET_ALL + ) count += 1 text = '=' text_handling.print_separator(text) # Interactions functions + def interact_hostel(map_zone, zone, player, drinks, item): logger_sys.log_message(f"INFO: Current map zone '{map_zone}' is an hostel --> can interact") text = '=' @@ -266,8 +318,8 @@ def interact_hostel(map_zone, zone, player, drinks, item): loading -= 1 logger_sys.log_message("INFO: Finished sleeping process") logger_sys.log_message("INFO: Updating correct day time to morning") - day_time = float( float(round(player["elapsed time game days"] + 1, 0)) + .25 ) - player["elapsed time game days"] = float( float(round(player["elapsed time game days"] + 1, 0)) + .25 ) + day_time = float(float(round(player["elapsed time game days"] + 1, 0)) + .25) + player["elapsed time game days"] = float(float(round(player["elapsed time game days"] + 1, 0)) + .25) continue_hostel_actions = False if player["health"] > player["max health"]: player["health"] = player["max health"] @@ -277,8 +329,11 @@ def interact_hostel(map_zone, zone, player, drinks, item): elif choice == 'Buy Drink': which_drink = input("Which drink do you want to buy? ") logger_sys.log_message(f"INFO: Player has chosen drink '{which_drink}' to drink") - if which_drink in zone[map_zone]["sells"]["drinks"] and ( drinks[which_drink]["gold"] * zone[map_zone]["cost value"] ) < player["gold"]: - drink_cost = str( drinks[which_drink]["gold"] * zone[map_zone]["cost value"] ) + if ( + which_drink in zone[map_zone]["sells"]["drinks"] + and (drinks[which_drink]["gold"] * zone[map_zone]["cost value"]) < player["gold"] + ): + drink_cost = str(drinks[which_drink]["gold"] * zone[map_zone]["cost value"]) logger_sys.log_message(f"INFO: Buying drink '{which_drink}' --> removed {drink_cost} gold from player") player["gold"] -= drinks[which_drink]["gold"] * zone[map_zone]["cost value"] if drinks[which_drink]["healing level"] == 999: @@ -289,36 +344,51 @@ def interact_hostel(map_zone, zone, player, drinks, item): logger_sys.log_message(f"INFO: Healed player {healing_level} hp") player["health"] += drinks[which_drink]["healing level"] else: - text = COLOR_YELLOW + "You cannot buy that items because it would cause your gold to be negative." + COLOR_RESET_ALL + text = ( + COLOR_YELLOW + "You cannot buy that items because it would cause your gold to be negative." + COLOR_RESET_ALL + ) logger_sys.log_message(f"INFO: Canceling buying process of drink '{which_drink}' --> doesn't have enough gold") text_handling.print_long_string(text) elif choice == 'Buy Item': which_item = input("Which item do you want to buy? ") logger_sys.log_message(f"INFO: Player has chosen item '{which_item}' to buy") - if which_item in zone[map_zone]["sells"]["items"] and ( item[which_item]["gold"] * zone[map_zone]["cost value"] ) < player["gold"]: + if ( + which_item in zone[map_zone]["sells"]["items"] + and (item[which_item]["gold"] * zone[map_zone]["cost value"]) < player["gold"] + ): if player["inventory slots remaining"] > 0: player["inventory slots remaining"] -= 1 logger_sys.log_message(f"INFO: Adding item '{which_item}' to player inventory") player["inventory"].append(which_item) - item_cost = str( item[which_item]["gold"] * zone[map_zone]["cost value"] ) + item_cost = str(item[which_item]["gold"] * zone[map_zone]["cost value"]) logger_sys.log_message(f"INFO: Removing {item_cost} gold from player") player["gold"] -= item[which_item]["gold"] * zone[map_zone]["cost value"] else: logger_sys.log_message("INFO: Canceling buying process --> doesn't have enough inventory slots") - text = COLOR_YELLOW + "You cannot buy that items because it would cause your inventory slots to be negative." + COLOR_RESET_ALL + text = ( + COLOR_YELLOW + "You cannot buy that items because it would cause your inventory slots to be negative." + + COLOR_RESET_ALL + ) text_handling.print_long_string(text) else: logger_sys.log_message("INFO: Canceling buying process --> doesn't have enough gold") - text = COLOR_YELLOW + "You cannot buy that items because it would cause your gold to be negative." + COLOR_RESET_ALL + text = ( + COLOR_YELLOW + "You cannot buy that items because it would cause your gold to be negative." + + COLOR_RESET_ALL + ) text_handling.print_long_string(text) elif choice == 'Sell Item': which_item = input("Which item do you want to sell? ") logger_sys.log_message(f"INFO: Player has chosen item '{which_item}' to sell") - if which_item in zone[map_zone]["buys"]["items"] and ( item[which_item]["gold"] * zone[map_zone]["cost value"] ) < player["gold"] and which_item in player["inventory"]: + if ( + which_item in zone[map_zone]["buys"]["items"] + and (item[which_item]["gold"] * zone[map_zone]["cost value"]) < player["gold"] + and which_item in player["inventory"] + ): logger_sys.log_message(f"INFO: Removing item '{which_item}' from player inventory") player["inventory slots remaining"] -= 1 logger_sys.log_message(f"INFO: Adding to player {gold} gold") - gold = str( item[which_item]["gold"] * zone[map_zone]["cost value"] ) + gold = str(item[which_item]["gold"] * zone[map_zone]["cost value"]) player["gold"] += item[which_item]["gold"] * zone[map_zone]["cost value"] player["inventory"].remove(which_item) which_item_number_inventory = 0 @@ -350,6 +420,7 @@ def interact_hostel(map_zone, zone, player, drinks, item): else: continue_hostel_actions = False + def interaction_stable(map_zone, zone, player, item, drinks, mounts, map_location, preferences): logger_sys.log_message(f"INFO: Current map zone '{map_zone}' is a stable --> can interact") options = ["Train Mount", "Deposit Mount", "Ride Mount"] @@ -370,27 +441,38 @@ def interaction_stable(map_zone, zone, player, item, drinks, mounts, map_locatio if action == 'Buy Item': which_item = input("Which item do you want to buy? ") logger_sys.log_message(f"INFO: Player has chosen item '{which_item}' to buy") - if which_item in zone[map_zone]["stable"]["sells"]["items"] and ( item[which_item]["gold"] * zone[map_zone]["cost value"] ) < player["gold"]: + if ( + which_item in zone[map_zone]["stable"]["sells"]["items"] + and (item[which_item]["gold"] * zone[map_zone]["cost value"]) < player["gold"] + ): if player["inventory slots remaining"] > 0: logger_sys.log_message(f"INFO: Adding item '{which_item}' from player inventory") player["inventory slots remaining"] -= 1 player["inventory"].append(which_item) logger_sys.log_message(f"INFO: Removing {gold} gold from player") - gold = str( item[which_item]["gold"] * zone[map_zone]["cost value"] ) + gold = str(item[which_item]["gold"] * zone[map_zone]["cost value"]) player["gold"] -= item[which_item]["gold"] * zone[map_zone]["cost value"] else: logger_sys.log_message("INFO: Canceling buying process -> doesn't gas enough inventory slots") - text = COLOR_YELLOW + "You cannot buy that items because it would cause your inventory slots to be negative." + COLOR_RESET_ALL + text = ( + COLOR_YELLOW + "You cannot buy that items because it would cause your inventory slots to be negative." + + COLOR_RESET_ALL + ) text_handling.print_long_string(text) else: logger_sys.log_message("INFO: Canceling buying process --> doesn't has enough gold") - text = COLOR_YELLOW + "You cannot buy that items because it would cause your gold to be negative." + COLOR_RESET_ALL + text = ( + COLOR_YELLOW + "You cannot buy that items because it would cause your gold to be negative." + COLOR_RESET_ALL + ) text_handling.print_long_string(text) elif action == 'Buy Drink': which_drink = input("Which drink do you want to buy? ") logger_sys.log_message(f"INFO: Player has chosen drink '{which_drink}' to buy") - if which_drink in zone[map_zone]["stable"]["sells"]["drinks"] and ( drinks[which_drink]["gold"] * zone[map_zone]["cost value"] ) < player["gold"]: - gold = str( drinks[which_drink]["gold"] * zone[map_zone]["cost value"] ) + if ( + which_drink in zone[map_zone]["stable"]["sells"]["drinks"] + and (drinks[which_drink]["gold"] * zone[map_zone]["cost value"]) < player["gold"] + ): + gold = str(drinks[which_drink]["gold"] * zone[map_zone]["cost value"]) logger_sys.log_message(f"INFO: Removing {gold} gold from player") player["gold"] -= drinks[which_drink]["gold"] * zone[map_zone]["cost value"] if drinks[which_drink]["healing level"] == 999: @@ -402,13 +484,15 @@ def interaction_stable(map_zone, zone, player, item, drinks, mounts, map_locatio player["health"] += drinks[which_drink]["healing level"] else: logger_sys.log_message("INFO: Canceling buying process --> doesn't have enough gold") - text = COLOR_YELLOW + "You cannot buy that items because it would cause your gold to be negative." + COLOR_RESET_ALL + text = ( + COLOR_YELLOW + "You cannot buy that items because it would cause your gold to be negative." + COLOR_RESET_ALL + ) text_handling.print_long_string(text) elif action == 'Buy Mount': which_mount = input("Which mount do you want to buy? ") logger_sys.log_message(f"INFO: Player has chosen mount '{which_mount}' to buy") if which_mount in zone[map_zone]["stable"]["sells"]["mounts"]: - mount_cost = ( mounts[which_mount]["gold"] * zone[map_zone]["cost value"] ) + mount_cost = (mounts[which_mount]["gold"] * zone[map_zone]["cost value"]) if mount_cost < player["gold"]: logger_sys.log_message(f"INFO: Removing player {mount_cost} gold") player["gold"] -= mount_cost @@ -448,7 +532,10 @@ def interaction_stable(map_zone, zone, player, item, drinks, mounts, map_locatio logger_sys.log_message(f"INFO: Created new mount stats: '{mount_dict}'") player["mounts"][generated_mount_uuid] = mount_dict logger_sys.log_message(f"INFO: Deposited new mount at map zone '{map_zone}'") - text = "Your mount is currently deposited at the " + zone[map_zone]["name"] + "\nYou can ride it whenever you want." + text = ( + "Your mount is currently deposited at the " + zone[map_zone]["name"] + + "\nYou can ride it whenever you want." + ) text_handling.print_speech_text_effect(text, preferences) text = '=' text_handling.print_separator(text) @@ -456,7 +543,11 @@ def interaction_stable(map_zone, zone, player, item, drinks, mounts, map_locatio logger_sys.log_message("INFO: Canceling buying process --> doesn't has enough gold") print(COLOR_YELLOW + "You don't own enough gold to buy that mount" + COLOR_RESET_ALL) else: - logger_sys.log_message(f"INFO: Canceling buying process --> current stable '{map_zone}' doesn't sell mount '{which_mount}'") + logger_sys.log_message( + f"INFO: Canceling buying process --> current stable '{ + map_zone + }' doesn't sell mount '{which_mount}'" + ) print(COLOR_YELLOW + "The current stable do not sell this mount" + COLOR_RESET_ALL) elif action == 'Deposit Mount': if player["current mount"] != " ": @@ -469,7 +560,11 @@ def interaction_stable(map_zone, zone, player, item, drinks, mounts, map_locatio if required_mount_stable in zone[map_zone]["stable"]["stables"]: ask = input("Do you want to deposit your current mount " + mount_data["name"] + " ? (y/n) ") if ask.lower().startswith('y'): - logger_sys.log_message(f"INFO: Depositing currently player ridden mount '{current_mount}' to map zone '{map_zone}") + logger_sys.log_message( + f"INFO: Depositing currently player ridden mount '{ + current_mount + }' to map zone '{map_zone}" + ) player["current mount"] = " " player["mounts"][current_mount_uuid]["is deposited"] = True player["mounts"][current_mount_uuid]["deposited day"] = round(player["elapsed time game days"], 1) @@ -477,7 +572,11 @@ def interaction_stable(map_zone, zone, player, item, drinks, mounts, map_locatio text = "=" text_handling.print_separator(text) else: - logger_sys.log_message(f"INFO: Canceling depositing process --> current stable '{map_zone}' doesn't accept mounts of type '{current_mount_type}'") + logger_sys.log_message( + f"INFO: Canceling depositing process --> current stable '{ + map_zone + }' doesn't accept mounts of type '{current_mount_type}'" + ) print(COLOR_YELLOW + "This stable doesn't accept this type of mount." + COLOR_RESET_ALL) else: logger_sys.log_message("INFO: Canceling depositing process --> doesn't ride any mounts by now") @@ -489,7 +588,9 @@ def interaction_stable(map_zone, zone, player, item, drinks, mounts, map_locatio train.training_loop(current_mount_uuid, player, item, mounts, zone[map_zone]) else: logger_sys.log_message("INFO: Canceling mount train process --> doesn't ride any mounts by now") - text = COLOR_YELLOW + "You're not riding any mounts currently. You need to ride one to train it." + COLOR_RESET_ALL + text = ( + COLOR_YELLOW + "You're not riding any mounts currently. You need to ride one to train it." + COLOR_RESET_ALL + ) text_handling.print_long_string(text) elif action == 'Ride Mount': if player["current mount"] == ' ': @@ -501,12 +602,15 @@ def interaction_stable(map_zone, zone, player, item, drinks, mounts, map_locatio deposited_mounts_names = [] if "None" not in list(player["mounts"]): while count < mounts_list_len: - selected_mount = list(player["mounts"])[count] - selected_mount = str(selected_mount) - if player["mounts"][selected_mount]["location"] == "point" + str(map_location) and player["mounts"][selected_mount]["is deposited"] == True: - deposited_mounts_num += 1 - deposited_mounts_names += [str(player["mounts"][selected_mount]["name"])] - count += 1 + selected_mount = list(player["mounts"])[count] + selected_mount = str(selected_mount) + if ( + player["mounts"][selected_mount]["location"] == "point" + + str(map_location) and player["mounts"][selected_mount]["is deposited"] + ): + deposited_mounts_num += 1 + deposited_mounts_names += [str(player["mounts"][selected_mount]["name"])] + count += 1 else: deposited_mounts_names = None deposited_mounts_num = 0 @@ -527,38 +631,55 @@ def interaction_stable(map_zone, zone, player, item, drinks, mounts, map_locatio count = 0 continue_searching = True which_mount_uuid = "" - while count < len(list(player["mounts"])) and continue_searching == True: + while count < len(list(player["mounts"])) and continue_searching: selected_mount_uuid = list(player["mounts"])[count] selected_mount_data = player["mounts"][selected_mount_uuid] if selected_mount_data["name"] == which_mount: continue_searching = False which_mount_uuid = str(selected_mount_uuid) count += 1 - mount_take_back_cost = round(( player["elapsed time game days"] - player["mounts"][which_mount_uuid]["deposited day"] ) * zone[map_zone]["deposit gold"], 2) - print("If you take back this mount it will cost you " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(mount_take_back_cost) + COLOR_RESET_ALL + " gold. ") + mount_take_back_cost = round( + ( + player["elapsed time game days"] - player["mounts"][which_mount_uuid]["deposited day"] + ) * zone[map_zone]["deposit gold"], 2 + ) + print( + "If you take back this mount it will cost you " + COLOR_YELLOW + + COLOR_STYLE_BRIGHT + str(mount_take_back_cost) + COLOR_RESET_ALL + " gold. " + ) ask = input("(y/n) ") if player["gold"] > mount_take_back_cost: if ask.lower().startswith('y'): - logger_sys.log_message(f"INFO: Removing {mount_take_back_cost} gold from player") - player["gold"] -= mount_take_back_cost - player["current mount"] = str(which_mount_uuid) - player["mounts"][which_mount_uuid]["is deposited"] = False - player["mounts"][which_mount_uuid]["deposited day"] = 0 - player["mounts"][which_mount_uuid]["location"] = "point" + str(map_location) + logger_sys.log_message(f"INFO: Removing {mount_take_back_cost} gold from player") + player["gold"] -= mount_take_back_cost + player["current mount"] = str(which_mount_uuid) + player["mounts"][which_mount_uuid]["is deposited"] = False + player["mounts"][which_mount_uuid]["deposited day"] = 0 + player["mounts"][which_mount_uuid]["location"] = "point" + str(map_location) else: logger_sys.log_message("INFO: Canceling taking back process --> doesn't has enough gold") print(COLOR_YELLOW + "You don't own enough gold to take back your mount." + COLOR_RESET_ALL) else: - logger_sys.log_message("INFO: Canceling taking back process --> doesn't own that mount or the mount isn't deposited at this current location") - text = COLOR_YELLOW + "You don't own that mount or the mount isn't deposited at this current location" + COLOR_RESET_ALL + logger_sys.log_message( + "INFO: Canceling taking back process --> doesn't own that mount " + + "or the mount isn't deposited at this current location" + ) + text = ( + COLOR_YELLOW + "You don't own that mount or the mount isn't deposited at this current location" + + COLOR_RESET_ALL + ) text_handling.print_long_string(text) else: logger_sys.log_message(f"INFO: Canceling taking back process --> already riding mount '{which_mount}'") - text = COLOR_YELLOW + "You are currently already riding a mount. You need to deposit your current mount before riding an other one." + COLOR_RESET_ALL + text = ( + COLOR_YELLOW + "You are currently already riding a mount. You need " + + "to deposit your current mount before riding an other one." + COLOR_RESET_ALL + ) text_handling.print_long_string(text) else: active_stable_menu = False + def interaction_blacksmith(map_zone, zone, item, player): logger_sys.log_message(f"INFO: Current map zone '{map_zone}' is a blacksmith --> can interact") text = '=' @@ -574,19 +695,30 @@ def interaction_blacksmith(map_zone, zone, item, player): which_weapon = input("Which equipment do you want to sell? ") logger_sys.log_message(f"INFO: Player has chosen item '{which_weapon}' to sell") if which_weapon in zone[map_zone]["blacksmith"]["buys"] and which_weapon in player["inventory"]: - gold = str( item[which_weapon]["gold"] * zone[map_zone]["cost value"] ) + gold = str(item[which_weapon]["gold"] * zone[map_zone]["cost value"]) player["gold"] += item[which_weapon]["gold"] * zone[map_zone]["cost value"] logger_sys.log_message(f"INFO: Adding to player {gold} gold") player["inventory"].remove(which_weapon) logger_sys.log_message(f"INFO: Removing item '{which_weapon}' from player inventory") else: - text = COLOR_YELLOW + "You cannot sell that equipment because you dont own any of that weapon or because the current blacksmith doesn't buy this weapon." + COLOR_RESET_ALL - logger_sys.log_message(f"INFO: Canceling selling process --> current blacksmith '{map_zone}' doesn't sell item '{which_weapon}' or player doesn't own item '{which_weapon}'") + text = ( + COLOR_YELLOW + "You cannot sell that equipment because you " + + "dont own any of that weapon or because the current blacksmith doesn't buy this weapon." + + COLOR_RESET_ALL + ) + logger_sys.log_message( + f"INFO: Canceling selling process --> current blacksmith '{ + map_zone + }' doesn't sell item '{which_weapon}' or player doesn't own item '{which_weapon}'" + ) text_handling.print_long_string(text) elif action == 'Order Equipment': which_weapon = input("Which equipment do you want to order? ") logger_sys.log_message(f"INFO: Player has chosen item '{which_weapon}' to order") - if which_weapon in zone[map_zone]["blacksmith"]["orders"] and player["gold"] > zone[map_zone]["blacksmith"]["orders"][which_weapon]["gold"]: + if ( + which_weapon in zone[map_zone]["blacksmith"]["orders"] + and player["gold"] > zone[map_zone]["blacksmith"]["orders"][which_weapon]["gold"] + ): required_items = False count = 0 required_items_number = 0 @@ -599,8 +731,8 @@ def interaction_blacksmith(map_zone, zone, item, player): if required_items_number == len(zone[map_zone]["blacksmith"]["orders"][which_weapon]["needed materials"]): required_items = True logger_sys.log_message("INFO: Player has required items --> continuing") - if required_items == True: - gold = str( item[which_weapon]["gold"] * zone[map_zone]["cost value"] ) + if required_items: + gold = str(item[which_weapon]["gold"] * zone[map_zone]["cost value"]) logger_sys.log_message(f"INFO: Removing from player {gold} gold") player["gold"] -= item[which_weapon]["gold"] * zone[map_zone]["cost value"] count = 0 @@ -623,11 +755,18 @@ def interaction_blacksmith(map_zone, zone, item, player): } logger_sys.log_message(f"Created order '{order_uuid}' dictionary: '{order_dict}'") player["orders"][order_uuid] = order_dict - text = "You'll be able to get your finished order in " + COLOR_MAGENTA + COLOR_STYLE_BRIGHT + str(zone[map_zone]["blacksmith"]["orders"][which_weapon]["time needed"]) + COLOR_RESET_ALL + " days." + text = ( + "You'll be able to get your finished order in " + COLOR_MAGENTA + + COLOR_STYLE_BRIGHT + str(zone[map_zone]["blacksmith"]["orders"][which_weapon]["time needed"]) + + COLOR_RESET_ALL + " days." + ) text_handling.print_long_string(text) else: logger_sys.log_message("INFO: Canceling ordering process --> doesn't have necessary items") - text = COLOR_YELLOW + "You cannot order that equipment because you dont have the necessary items." + COLOR_RESET_ALL + text = ( + COLOR_YELLOW + "You cannot order that equipment because you dont have the necessary items." + + COLOR_RESET_ALL + ) text_handling.print_long_string(text) else: logger_sys.log_message("INFO: Canceling ordering process --> doesn't has enough gold") @@ -652,7 +791,7 @@ def interaction_blacksmith(map_zone, zone, item, player): if required_items_number == len(item[str(item_next_upgrade_name)]["for this upgrade"]): required_items = True logger_sys.log_message("INFO: Player has required items for --< continuing") - if required_items == True: + if required_items: gold = str(item[item_next_upgrade_name]["gold"]) logger_sys.log_message(f"INFO: Removing from player {gold} gold") player["gold"] -= item[item_next_upgrade_name]["gold"] @@ -676,7 +815,11 @@ def interaction_blacksmith(map_zone, zone, item, player): } logger_sys.log_message(f"Created order '{order_uuid}' dictionary: '{order_dict}'") player["orders"][order_uuid] = order_dict - text = "You'll be able to get your finished order in " + COLOR_MAGENTA + COLOR_STYLE_BRIGHT + str(player["orders"][order_uuid]["time needed"]) + COLOR_RESET_ALL + " days." + text = ( + "You'll be able to get your finished order in " + COLOR_MAGENTA + + COLOR_STYLE_BRIGHT + str(player["orders"][order_uuid]["time needed"]) + + COLOR_RESET_ALL + " days." + ) text_handling.print_long_string(text) else: logger_sys.log_message("INFO: Canceling upgrading process --> doesn't has the necessary items") @@ -685,10 +828,16 @@ def interaction_blacksmith(map_zone, zone, item, player): logger_sys.log_message("INFO: Canceling upgrading process --> doesn't has enough gold") print(COLOR_YELLOW + "You don't have enough gold to upgrade." + COLOR_RESET_ALL) else: - logger_sys.log_message(f"INFO: Canceling upgrading process --> cannot upgrade equipment '{which_weapon}' further") - print(COLOR_YELLOW + "You cannot upgrade this equipment further." + COLOR_RESET_ALL) + logger_sys.log_message( + f"INFO: Canceling upgrading process --> cannot upgrade equipment '{which_weapon}' further" + ) + print( + COLOR_YELLOW + "You cannot upgrade this equipment further." + COLOR_RESET_ALL + ) else: - logger_sys.log_message(f"INFO: Canceling upgrading process --> player doesn't own any '{which_weapon}' in its inventory") + logger_sys.log_message(f"INFO: Canceling upgrading process --> player doesn't own any '{ + which_weapon + }' in its inventory") print(COLOR_YELLOW + "You don't own that equipment" + COLOR_RESET_ALL) elif action == 'Check Order': player_orders = player["orders"] @@ -707,7 +856,7 @@ def interaction_blacksmith(map_zone, zone, item, player): try: ordered_blacksmith = selected_order["ordered blacksmith"] ordered_weapon = selected_order["ordered weapon"] - except: + except Exception: print(ordered_blacksmith, ordered_weapon) if ordered_blacksmith == zone[map_zone]["name"]: ordered_weapon_syntax = ordered_weapon + " {" + str(count) + "}" @@ -731,13 +880,25 @@ def interaction_blacksmith(map_zone, zone, item, player): text = '=' text_handling.print_separator(text) - time_left = round(player["orders"][current_order_uuid]["ordered day"] + player["orders"][current_order_uuid]["time needed"] - player["elapsed time game days"], 1) + time_left = round( + player["orders"][current_order_uuid]["ordered day"] + + player["orders"][current_order_uuid]["time needed"] - player["elapsed time game days"], 1 + ) if time_left <= 0: time_left = "READY TO COLLECT" logger_sys.log_message(f"INFO: Printing order '{current_order_uuid}' information to GUI") - print("ORDERED EQUIPMENT: " + COLOR_RED + str(player["orders"][current_order_uuid]["ordered weapon"]) + COLOR_RESET_ALL) - print("PAID GOLD: " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + str(round(player["orders"][current_order_uuid]["paid gold"], 1)) + COLOR_RESET_ALL) - print("ORDERED DAY: " + COLOR_MAGENTA + COLOR_STYLE_BRIGHT + str(round(player["orders"][current_order_uuid]["ordered day"], 1)) + COLOR_RESET_ALL) + print( + "ORDERED EQUIPMENT: " + COLOR_RED + + str(player["orders"][current_order_uuid]["ordered weapon"]) + COLOR_RESET_ALL + ) + print( + "PAID GOLD: " + COLOR_YELLOW + COLOR_STYLE_BRIGHT + + str(round(player["orders"][current_order_uuid]["paid gold"], 1)) + COLOR_RESET_ALL + ) + print( + "ORDERED DAY: " + COLOR_MAGENTA + COLOR_STYLE_BRIGHT + + str(round(player["orders"][current_order_uuid]["ordered day"], 1)) + COLOR_RESET_ALL + ) print("TIME LEFT: " + COLOR_CYAN + COLOR_STYLE_BRIGHT + str(time_left) + COLOR_RESET_ALL) text = '=' @@ -749,15 +910,18 @@ def interaction_blacksmith(map_zone, zone, item, player): action = term_menu.show_menu(options_order) logger_sys.log_message(f"INFO: Player has chosen option '{action}'") if action == 'Cancel Order': - text = "Are you sure you want to cancel this order? You will receive 75% of the gold you paid and you won't be able" + text = ( + "Are you sure you want to cancel this order? You will receive " + + "75% of the gold you paid and you won't be able" + ) text_handling.print_long_string(text) - ask =input(" to get your given items back. (y/n)") + ask = input(" to get your given items back. (y/n)") if ask.lower().startswith('y'): # give player 75% of paid gold gold = player["orders"][current_order_uuid]["paid gold"] - gold2 = player["orders"][current_order_uuid]["paid gold"] * ( 75 / 100 ) + gold2 = player["orders"][current_order_uuid]["paid gold"] * (75 / 100) logger_sys.log_message(f"INFO: Giving back player 75% of the paid gold: {gold} * 100 / 75 = {gold2}") - player["gold"] += player["orders"][current_order_uuid]["paid gold"] * ( 75 / 100 ) + player["gold"] += player["orders"][current_order_uuid]["paid gold"] * (75 / 100) # remove order from player orders player["orders"].pop(current_order_uuid) if action == 'Collect Order': @@ -767,11 +931,16 @@ def interaction_blacksmith(map_zone, zone, item, player): # remove order from player orders player["orders"].pop(current_order_uuid) else: - logger_sys.log_message(f"INFO: Canceling collecting order process --> player has no order '{which_order}' at map zone '{map_zone}'") + logger_sys.log_message( + f"INFO: Canceling collecting order process --> player has no order '{ + which_order + }' at map zone '{map_zone}'" + ) print(COLOR_YELLOW + "You don't have this order currently at this place." + COLOR_RESET_ALL) else: continue_blacksmith_actions = False + def interaction_forge(map_zone, zone, player, item): logger_sys.log_message(f"INFO: map zone '{map_zone}' is a forge --> can interact") current_forge = zone[map_zone] @@ -804,10 +973,16 @@ def interaction_forge(map_zone, zone, player, item): player["inventory"].remove(which_metal) count += 1 else: - logger_sys.log_message(f"INFO: Canceling selling process --> doesn't has {metal_count} '{which_metal}' in player's inventory") + logger_sys.log_message( + f"INFO: Canceling selling process --> doesn't has { + metal_count + } '{which_metal}' in player's inventory" + ) print(COLOR_YELLOW + "You don't own that many count of this metal" + COLOR_RESET_ALL) else: - logger_sys.log_message(f"INFO: Canceling selling process --> current forge '{map_zone}' doesn't sell metal '{which_metal}'") + logger_sys.log_message( + f"INFO: Canceling selling process --> current forge '{map_zone}' doesn't sell metal '{which_metal}'" + ) print(COLOR_YELLOW + "The current forge doesn't buys this metal" + COLOR_RESET_ALL) elif choice == 'Buy Metals': which_metal = input("Which metal do you want to buy? ") @@ -827,10 +1002,15 @@ def interaction_forge(map_zone, zone, player, item): logger_sys.log_message(f"INFO: Canceling buying process --> doesn't have enough gold") print(COLOR_YELLOW + "You don't own enough gold to buy that many metal" + COLOR_RESET_ALL) else: - logger_sys.log_message(f"INFO: Canceling buying process --> current forge '{map_zone}' doesn't sell item '{which_metal}'") + logger_sys.log_message( + f"INFO: Canceling buying process --> current forge '{ + map_zone + }' doesn't sell item '{which_metal}'" + ) print(COLOR_YELLOW + "The current forge doesn't sells this metal" + COLOR_RESET_ALL) else: continue_forge_actions = False + # deinitialize colorama deinit()