Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGFIX: Fix Weapon Upgrading Issues (#15) And Another Bug #32

Merged
merged 4 commits into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions source/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand All @@ -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 <direction>, simply say <direction>." + 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)
Expand All @@ -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)
Expand All @@ -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"])
Expand All @@ -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"])
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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":
Expand All @@ -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")
Expand Down Expand Up @@ -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"]:
Expand Down Expand Up @@ -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}'")
Expand Down
2 changes: 1 addition & 1 deletion source/weapon_upgrade_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'")
Expand Down
28 changes: 14 additions & 14 deletions source/zone_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading