Updated the Run classes to properly reference the _do_run variables so changes to runs in bot.py will persist into Run classes

This commit is contained in:
Randi
2026-03-19 19:09:39 -04:00
parent 466197fd8b
commit 95e019e88d
7 changed files with 31 additions and 17 deletions

View File

@@ -116,18 +116,17 @@ class Bot:
# Adapt order to the config
self._do_runs = OrderedDict((k, self._do_runs[k]) for k in Config().routes_order if k in self._do_runs and self._do_runs[k])
runs = list(self._do_runs.keys())
self._do_runs_reset = copy(self._do_runs)
Logger.info(f"Doing runs: {self._do_runs_reset.keys()}")
if Config().general["randomize_runs"]:
self.shuffle_runs()
self._pindle = Pindle(self._pather, self._town_manager, self._char, self._pickit, runs)
self._shenk = ShenkEld(self._pather, self._town_manager, self._char, self._pickit, runs)
self._trav = Trav(self._pather, self._town_manager, self._char, self._pickit, runs)
self._nihlathak = Nihlathak(self._pather, self._town_manager, self._char, self._pickit, runs)
self._arcane = Arcane(self._pather, self._town_manager, self._char, self._pickit, runs)
self._diablo = Diablo(self._pather, self._town_manager, self._char, self._pickit, runs)
self._vizier = Vizier(self._pather, self._town_manager, self._char, self._pickit, runs)
self._pindle = Pindle(self._pather, self._town_manager, self._char, self._pickit, self._do_runs)
self._shenk = ShenkEld(self._pather, self._town_manager, self._char, self._pickit, self._do_runs)
self._trav = Trav(self._pather, self._town_manager, self._char, self._pickit, self._do_runs)
self._nihlathak = Nihlathak(self._pather, self._town_manager, self._char, self._pickit, self._do_runs)
self._arcane = Arcane(self._pather, self._town_manager, self._char, self._pickit, self._do_runs)
self._diablo = Diablo(self._pather, self._town_manager, self._char, self._pickit, self._do_runs)
self._vizier = Vizier(self._pather, self._town_manager, self._char, self._pickit, self._do_runs)
# Create member variables
self._picked_up_items = False
@@ -216,7 +215,10 @@ class Bot:
def shuffle_runs(self):
tmp = list(self._do_runs.items())
random.shuffle(tmp)
self._do_runs = OrderedDict(tmp)
#We clear() and update() to avoid assignment on _do_runs as this list is referenced
#by other classes and we want updates persisted everywhere.
self._do_runs.clear()
self._do_runs.update(OrderedDict(tmp))
def is_last_run(self):
found_unfinished_run = False
@@ -484,8 +486,10 @@ class Bot:
self._timer = time.time()
self._do_runs = copy(self._do_runs_reset)
#We clear() and update() to avoid assignment on _do_runs as this list is referenced
#by other classes and we want updates persisted everywhere.
self._do_runs.clear()
self._do_runs.update(self._do_runs_reset)
if Config().general["randomize_runs"]:
self.shuffle_runs()
self.trigger_or_stop("init")

View File

@@ -10,6 +10,7 @@ from dataclasses import dataclass
from chest import Chest
from ui import waypoint
from health_manager import set_pause_state
from collections import OrderedDict
class Arcane:
@@ -21,7 +22,7 @@ class Arcane:
town_manager: TownManager,
char: IChar,
pickit: PickIt,
runs: list[str]
runs: OrderedDict
):
self._pather = pather
self._town_manager = town_manager

View File

@@ -13,6 +13,7 @@ from screen import convert_abs_to_monitor, grab
from ui_manager import detect_screen_object, ScreenObjects
from ui import skills, loading, waypoint
from inventory import belt, personal
from collections import OrderedDict
class Diablo:
@@ -24,7 +25,7 @@ class Diablo:
town_manager: TownManager,
char: IChar,
pickit: PickIt,
runs: list[str]
runs: OrderedDict
):
self._pather = pather
self._town_manager = town_manager

View File

@@ -10,6 +10,7 @@ from screen import convert_abs_to_monitor
import random
from ui import loading, waypoint
from collections import OrderedDict
class Nihlathak:
@@ -21,7 +22,7 @@ class Nihlathak:
town_manager: TownManager,
char: IChar,
pickit: PickIt,
runs: list[str]
runs: OrderedDict
):
self._pather = pather
self._town_manager = town_manager

View File

@@ -6,6 +6,7 @@ import template_finder
from town.town_manager import TownManager
from utils.misc import wait
from ui import loading
from collections import OrderedDict
class Pindle:
@@ -17,7 +18,7 @@ class Pindle:
town_manager: TownManager,
char: IChar,
pickit: PickIt,
runs: list[str]
runs: OrderedDict
):
self._pather = pather
self._town_manager = town_manager

View File

@@ -6,6 +6,7 @@ import template_finder
from town.town_manager import TownManager
from utils.misc import wait
from ui import waypoint
from collections import OrderedDict
class ShenkEld:
@@ -17,7 +18,7 @@ class ShenkEld:
town_manager: TownManager,
char: IChar,
pickit: PickIt,
runs: list[str]
runs: OrderedDict
):
self._pather = pather
self._town_manager = town_manager

View File

@@ -7,6 +7,7 @@ from town.town_manager import TownManager
from utils.misc import wait
from ui import waypoint
from collections import OrderedDict
class Trav:
@@ -18,7 +19,7 @@ class Trav:
town_manager: TownManager,
char: IChar,
pickit: PickIt,
runs: list[str]
runs: OrderedDict
):
self._pather = pather
self._town_manager = town_manager
@@ -57,4 +58,8 @@ class Trav:
if not self._pather.traverse_nodes([229], self._char, timeout=2.5, use_tp_charge=self._char.capabilities.can_teleport_natively):
self._pather.traverse_nodes([228, 229], self._char, timeout=2.5, use_tp_charge=True)
picked_up_items |= self._pickit.pick_up_items(self._char)
# If travincal run is not the last run
if self.name != next(reversed(self._runs)):
# Make sure we go back to the center to not hide the tp
self._pather.traverse_nodes([230], self._char, timeout=2.5)
return (Location.A3_TRAV_CENTER_STAIRS, picked_up_items)