diff --git a/source/main.py b/source/main.py index 43af09e..0db892c 100644 --- a/source/main.py +++ b/source/main.py @@ -1367,6 +1367,7 @@ def run(play): logger_sys.log_message(f"INFO: Player ran command '{command}'") logger_sys.log_message(f"INFO: Checking if a ground item is present at map point 'point{map_location}'") + continued_command = False if "item" in map["point" + str(map_location)] and command in map["point" + str(map_location)]["item"]: logger_sys.log_message(f"INFO: Found item '{command}' at map point 'point{map_location}'") if command in player["inventory"] and item[command]["type"] == "Utility": @@ -1380,9 +1381,12 @@ def run(play): logger_sys.log_message(f"INFO: Adding map point 'point{map_location}' to the player save attribute 'taken items'") player["inventory"].append(command) player["taken items"].append(map_location) + + continued_command = True elif command.lower().startswith('go'): print(COLOR_YELLOW + "Rather than saying Go , simply say ." + COLOR_RESET_ALL) time.sleep(1.5) + continued_command = True elif command.lower().startswith('n'): logger_sys.log_message(f"INFO: Checking if player can go north from map point 'point{map_location}'") next_point = search(player["x"], player["y"] + 1) @@ -1396,6 +1400,7 @@ def run(play): else: logger_sys.log_message(f"INFO: Moving player north to map point 'point{next_point}': successful checks") player["y"] += 1 + continued_command = True elif command.lower().startswith('s'): logger_sys.log_message(f"INFO: Checking if player can go south from map point 'point{map_location}'") next_point = search(player["x"], player["y"] - 1) @@ -1409,6 +1414,7 @@ def run(play): else: logger_sys.log_message(f"INFO: Moving player south to map point 'point{next_point}': successful checks") player["y"] -= 1 + continued_command = True elif command.lower().startswith('e'): logger_sys.log_message(f"INFO: Checking if player can go east from map point 'point{map_location}'") next_point = search(player["x"] + 1, player["y"]) @@ -1422,6 +1428,7 @@ def run(play): else: logger_sys.log_message(f"INFO: Moving player east to map point 'point{next_point}': successful checks") player["x"] += 1 + continued_command = True elif command.lower().startswith('w'): logger_sys.log_message(f"INFO: Checking if player can go west from map point 'point{map_location}'") next_point = search(player["x"] - 1, player["y"]) @@ -1435,6 +1442,7 @@ def run(play): else: logger_sys.log_message(f"INFO: Moving player west to map point 'point{next_point}': successful checks") player["x"] -= 1 + continued_command = True elif command.lower().startswith('d'): text = '=' text_handling.print_separator(text) @@ -1944,6 +1952,7 @@ def run(play): print(COLOR_YELLOW + "You do not currently have a mission named like that" + COLOR_RESET_ALL) logger_sys.log_message(f"INFO: Player doesn't know about mission '{which_task}' --> canceling") time.sleep(1.5) + continued_command = True elif command.lower().startswith('i'): text = '=' text_handling.print_separator(text) @@ -2044,7 +2053,7 @@ def run(play): 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)) + 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) @@ -2162,6 +2171,7 @@ def run(play): logger_sys.log_message(f"INFO: Canceling item action --> player doesn't own item '{which_item}'") print(COLOR_YELLOW + "You do not have that item." + COLOR_RESET_ALL) time.sleep(1.5) + continued_command = True elif command.lower().startswith('z'): logger_sys.log_message(f"INFO: Trying to interact with current zone '{map_zone}'") if zone[map_zone]["type"] == "hostel": @@ -2176,6 +2186,7 @@ def run(play): logger_sys.log_message(f"INFO: Map zone '{map_zone}' cannot have interactions") print(COLOR_YELLOW + "You cannot find any near hostel, stable, blacksmith, forge or church." + COLOR_RESET_ALL) time.sleep(1.5) + continued_command = True elif command.lower().startswith('y'): if "mounts" in player and player["mounts"] != '': logger_sys.log_message("INFO: Printing player currently ridden mount") @@ -2325,14 +2336,15 @@ def run(play): logger_sys.log_message(f"INFO: Canceling mount examining process --> player doesn't own any mounts") print(COLOR_YELLOW + "It seems you don't own any mounts." + COLOR_RESET_ALL) time.sleep(1.5) + continued_command = True elif command.lower().startswith('q'): logger_sys.log_message("INFO: Closing & Saving game") print(separator) play = 0 + continued_command = True else: - continued = False for i in utilities_list: - continued = True + continued_command = True continued2 = False current_utility = i if command == item[current_utility]["key"] and current_utility in player["inventory"]: @@ -2386,11 +2398,12 @@ def run(play): time.sleep(2) print(" ") - if not continued: + if not continued_command: logger_sys.log_message(f"INFO: chosen command '{command}' is not a valid command") print("'" + command + "' is not a valid command") time.sleep(2) print(" ") + # get end time end_time = time.time() logger_sys.log_message(f"INFO: Getting end time: '{end_time}'") diff --git a/source/weapon_upgrade_handling.py b/source/weapon_upgrade_handling.py index 3b730dc..5cd242d 100644 --- a/source/weapon_upgrade_handling.py +++ b/source/weapon_upgrade_handling.py @@ -13,7 +13,7 @@ def check_for_item(item_name, item): 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) - check_weapon_max_upgrade_number = check_weapon_max_upgrade(str(weapon_next_upgrade_name)) + check_weapon_max_upgrade_number = check_weapon_max_upgrade(str(weapon_next_upgrade_name), item) if item[weapon_next_upgrade_name]["upgrade tier"] == check_weapon_max_upgrade_number: weapon_next_upgrade_name = None logger_sys.log_message(f"INFO: No next upgrade found for equipment '{item_name}'") diff --git a/source/zone_handling.py b/source/zone_handling.py index c3d3068..b292e7f 100644 --- a/source/zone_handling.py +++ b/source/zone_handling.py @@ -779,26 +779,26 @@ def interaction_blacksmith(map_zone, zone, item, player): item_next_upgrade_name = str(weapon_upgrade_handling.check_weapon_next_upgrade_name(which_weapon, item)) if item_next_upgrade_name != 'None': if player["gold"] > item[item_next_upgrade_name]["gold"]: - required_items = False - count = 0 - required_items_number = 0 - fake_player_inventory = player["inventory"] - while count < len(fake_player_inventory): - selected_item = fake_player_inventory[count] - if selected_item in item[str(item_next_upgrade_name)]["for this upgrade"]: - required_items_number += 1 - count += 1 - 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: + finished = False + has_required_items = True + player_fake_inventory = player["inventory"] + required_items = [] + for i in player_fake_inventory: + if i in item[item_next_upgrade_name]["for this upgrade"]: + required_items.append(i) + while has_required_items and not finished: + for i in item[item_next_upgrade_name]["for this upgrade"]: + if required_items.count(i) < item[item_next_upgrade_name]["for this upgrade"].count(i): + has_required_items = False + finished = True + if has_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"] player["inventory"].remove(which_weapon) count = 0 remaining_items_to_remove = len(item[str(item_next_upgrade_name)]["for this upgrade"]) - while count < len(player["inventory"]) and remaining_items_to_remove != 0: + while count < len(player["inventory"]) and remaining_items_to_remove > 0: selected_item = item[str(item_next_upgrade_name)]["for this upgrade"][count] player["inventory"].remove(selected_item) remaining_items_to_remove -= 1