From 5ae6194d23f89167ed413d64de3e61debe1d2e7f Mon Sep 17 00:00:00 2001 From: RB-Development <35841825+RB-Development@users.noreply.github.com> Date: Sun, 6 Feb 2022 18:09:50 +0100 Subject: [PATCH] gambling bugfix (#519) * Update ui_manager.py Fix for gambling issue. Looks like self._config.char["gamble_items"] always returns true. Therefore im checking if the first entry is empty and go for a not. not self._config.char["gamble_items"][0]=="" * simplify Co-authored-by: mgleed --- src/bot.py | 10 ++++------ src/config.py | 2 +- src/ui/ui_manager.py | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/bot.py b/src/bot.py index 4157dd3..18d61a0 100644 --- a/src/bot.py +++ b/src/bot.py @@ -345,17 +345,15 @@ class Bot: return self.trigger_or_stop("end_game", failed=True) # Check if gambling is needed - gambling = self._ui_manager.gambling_needed() - if gambling: + if self._ui_manager.gambling_needed() and self._config.char["gamble_items"]: for x in range (4): self._curr_loc = self._town_manager.gamble(self._curr_loc) self._ui_manager.gamble(self._item_finder) if (x ==3): - self._curr_loc = self._town_manager.stash (self._curr_loc) + self._curr_loc = self._town_manager.stash(self._curr_loc) else: - self._curr_loc = self._town_manager.stash (self._curr_loc, gamble=gambling) - - self._ui_manager.set__gold_full (False) + self._curr_loc = self._town_manager.stash(self._curr_loc, gamble=True) + self._ui_manager.set__gold_full(False) # Start a new run started_run = False diff --git a/src/config.py b/src/config.py index 9471dbc..76c2852 100644 --- a/src/config.py +++ b/src/config.py @@ -243,7 +243,7 @@ class Config: "atk_len_cs_trashmobs": float(Config._select_val("char", "atk_len_cs_trashmobs")), "kill_cs_trash": float(Config._select_val("char", "kill_cs_trash")), "runs_per_repair": False if not Config._select_val("char", "runs_per_repair") else int(Config._select_val("char", "runs_per_repair")), - "gamble_items": Config._select_val("char", "gamble_items").replace(" ","").split(","), + "gamble_items": False if not Config._select_val("char", "gamble_items") else Config._select_val("char", "gamble_items").replace(" ","").split(","), } # Sorc base config sorc_base_cfg = dict(Config._config["sorceress"]) diff --git a/src/ui/ui_manager.py b/src/ui/ui_manager.py index c02a292..d37085d 100644 --- a/src/ui/ui_manager.py +++ b/src/ui/ui_manager.py @@ -416,7 +416,7 @@ class UiManager(): cv2.imwrite("./info_screenshots/info_gold_stash_full_" + time.strftime("%Y%m%d_%H%M%S") + ".png", self._screen.grab()) if self._curr_stash["gold"] > 3: #decide if gold pickup should be disabled or gambling is active - if (self._config.char["gamble_items"]): + if self._config.char["gamble_items"]: self._gold_full = True else: # turn off gold pickup @@ -760,4 +760,4 @@ if __name__ == "__main__": template_finder = TemplateFinder(screen) item_finder = ItemFinder() ui_manager = UiManager(screen, template_finder, game_stats) - ui_manager.gamble (item_finder) \ No newline at end of file + ui_manager.gamble (item_finder)