chore: commit all changes

This commit is contained in:
alex
2026-05-31 12:51:21 +02:00
parent 7d6314b575
commit 7d1f03beb7
13 changed files with 14657 additions and 19823 deletions
+19 -9
View File
@@ -586,16 +586,26 @@ class Bot:
self._do_runs[run_name] = False
self._game_stats.log_run_started(run_name)
self._curr_loc = run_obj.approach(self._curr_loc, *approach_args)
if self._curr_loc:
set_pause_state(False)
try:
res = run_obj.battle(*battle_args)
except Exception as e:
error_msg = f"{type(e).__name__}: {e}"
Logger.error(f"Exception during {run_name}: {error_msg}")
self._game_stats.set_failure_reason(error_msg)
res = False
if not self._curr_loc:
# Approach failed — couldn't reach the boss
self._game_stats.set_failure_reason(f"Approach failed for {run_name}")
picked = None
self._game_stats.log_run_finished(run_name, True, picked)
self._ending_run_helper(res)
return
set_pause_state(False)
try:
res = run_obj.battle(*battle_args)
except Exception as e:
error_msg = f"{type(e).__name__}: {e}"
Logger.error(f"Exception during {run_name}: {error_msg}")
self._game_stats.set_failure_reason(error_msg)
res = False
picked = res[1] if isinstance(res, tuple) and len(res) > 1 else None
if not bool(res):
# Battle failed — boss fight didn't complete
if not self._game_stats.get_failure_reason():
self._game_stats.set_failure_reason(f"Battle failed for {run_name}")
self._game_stats.log_run_finished(run_name, not bool(res), picked)
self._ending_run_helper(res)
+2 -2
View File
@@ -113,7 +113,7 @@ class TownManager:
if consumables.get_needs("health") > 0:
can_shift_click = not sum([ x > 0 for x in [consumables.get_needs("health"), consumables.get_needs("mana"), consumables.get_needs("rejuv")]]) > 1
if buy_best_available_potion(
["SUPER_HEALING_POTION", "GREATER_HEALING_POTION", "HEALING_POTION", "LIGHT_HEALING_POTION", "MINOR_HEALING_POTION"],
["SUPER_HEALING_POTION", "GREATER_HEALING_POTION"],
quantity=consumables.get_needs("health"),
shift_click=can_shift_click,
):
@@ -124,7 +124,7 @@ class TownManager:
if consumables.get_needs("mana") > 0:
can_shift_click = not sum([ x > 0 for x in [consumables.get_needs("health"), consumables.get_needs("mana"), consumables.get_needs("rejuv")]]) > 1
if buy_best_available_potion(
["SUPER_MANA_POTION", "GREATER_MANA_POTION", "MANA_POTION", "LIGHT_MANA_POTION", "MINOR_MANA_POTION"],
["SUPER_MANA_POTION", "GREATER_MANA_POTION"],
quantity=consumables.get_needs("mana"),
shift_click=can_shift_click,
):
+12 -1
View File
@@ -40,7 +40,18 @@ def select_tp(tp_hotkey):
["TELE_ACTIVE", "TELE_INACTIVE"]):
keyboard.send(tp_hotkey)
wait(0.1, 0.2)
return is_right_skill_selected(["TELE_ACTIVE", "TELE_INACTIVE"])
if is_right_skill_selected(["TELE_ACTIVE", "TELE_INACTIVE"]):
return True
# Charged teleport icons don't match TELE_ACTIVE/TELE_INACTIVE templates.
# If a hotkey is set, trust it was pressed and check for charge indicator.
if tp_hotkey:
img = grab()
skill_img = cut_roi(img, Config().ui_roi["skill_right"])
charge_mask, _ = color_filter(skill_img, Config().colors["blue"])
if np.sum(charge_mask) > 0:
Logger.debug("select_tp: detected charged teleport via blue charge indicator")
return True
return False
def is_right_skill_active() -> bool:
"""
+2 -1
View File
@@ -3,6 +3,7 @@ import os
import shutil
from config import Config
from logger import Logger
from mss import mss
from utils.misc import close_down_bnet_launcher, close_down_d2, only_lowercase_letters
@@ -54,7 +55,7 @@ def restore_settings_from_backup():
backup_file = f"{d2_saved_games}/Settings_backup.json"
current_file = f"{d2_saved_games}/Settings.json"
if not os.path.exists(backup_file):
print("No D2R settings backup file was found, couldn't restore.")
Logger.debug("No D2R settings backup file found, skipping restore.")
return
close_down_d2()
try: