Check if repairing is needed (#233)

This commit is contained in:
aeon0
2021-12-08 09:28:19 +01:00
committed by GitHub
parent 2efcd66d99
commit ca9e459de6
5 changed files with 16 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -112,6 +112,7 @@ hero_selection_logo=0,0,367,553
play_btn=427,613,213,67
window_ingame_ref=600,650,90,90
no_pickup=5,530,240,65
repair_needed=1000,0,280,280
[path]
pindle_save_dist=921,35, 1123,70, 960,88

View File

@@ -193,9 +193,11 @@ class Bot:
return self.trigger_or_stop("end_game")
wait(1.0)
# Check if we are out of tps
if self._tps_left < 3:
Logger.info("Repairing and buying TPs at next Vendor")
# Check if we are out of tps or need repairing
need_repair = self._ui_manager.repair_needed()
if self._tps_left < random.randint(2, 5) or need_repair:
if need_repair: Logger.info("Repair needed. Gear is about to break")
else: Logger.info("Repairing and buying TPs at next Vendor")
self._curr_loc = self._town_manager.repair_and_fill_tps(self._curr_loc)
if not self._curr_loc:
return self.trigger_or_stop("end_game")

View File

@@ -184,7 +184,7 @@ if __name__ == "__main__":
config = Config()
screen = Screen(config.general["monitor"])
template_finder = TemplateFinder(screen)
search_templates = ["A3_TOWN_1"]
search_templates = ["REPAIR_NEEDED"]
while 1:
# img = cv2.imread("")
img = screen.grab()

View File

@@ -447,8 +447,7 @@ class UiManager():
roi=self._config.ui_roi["skill_right"],
best_match=True,
threshold=0.79,
time_out=4
)
time_out=4)
if not template_match.valid:
Logger.warning("You are out of tps")
if self._config.general["info_screenshots"]:
@@ -457,6 +456,14 @@ class UiManager():
else:
return False
def repair_needed(self) -> bool:
template_match = self._template_finder.search(
"REPAIR_NEEDED",
self._screen.grab(),
roi=self._config.ui_roi["repair_needed"],
use_grayscale=True)
return template_match.valid
def enable_no_pickup(self) -> bool:
"""
Checks the best match between enabled and disabled an retrys if already set.