Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
try again on save and exit
Browse files Browse the repository at this point in the history
  • Loading branch information
aeon0 committed Nov 12, 2021
1 parent 7dd5465 commit c22f133
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/ui_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def check_free_belt_spots(self) -> bool:
return True
return False

def save_and_exit(self) -> bool:
def save_and_exit(self, does_chicken: bool = False) -> bool:
"""
Performes save and exit action from within game
:return: Bool if action was successful
Expand All @@ -136,14 +136,23 @@ def save_and_exit(self) -> bool:
keyboard.send("esc")
wait(0.1)
exit_btn_pos = (self._config.ui_pos["save_and_exit_x"], self._config.ui_pos["save_and_exit_y"])
found, _ = self._template_finder.search_and_wait(["SAVE_AND_EXIT_NO_HIGHLIGHT","SAVE_AND_EXIT_HIGHLIGHT"], roi=self._config.ui_roi["save_and_exit"], time_out=7)
if found:
x_m, y_m = self._screen.convert_screen_to_monitor(exit_btn_pos)
mouse.move(x_m, y_m, randomize=12)
wait(0.1)
away_x_m, away_y_m = self._screen.convert_screen_to_monitor((200, 450))
while self._template_finder.search_and_wait(["SAVE_AND_EXIT_NO_HIGHLIGHT","SAVE_AND_EXIT_HIGHLIGHT"], roi=self._config.ui_roi["save_and_exit"], time_out=1.5)[0]:
delay = [0.9, 1.1]
if does_chicken:
delay = [0.3, 0.4]
mouse.move(x_m, y_m, randomize=[60, 10], delay_factor=delay)
wait(0.03, 0.06)
mouse.click(button="left")
if does_chicken:
# lets just try again just in case
wait(0.05, 0.08)
mouse.click(button="left")
wait(0.1, 0.2)
mouse.move(away_x_m, away_y_m, randomize=100, delay_factor=[0.6, 0.9])
wait(0.1, 0.5)
return True

return False

def start_game(self) -> bool:
Expand Down

0 comments on commit c22f133

Please sign in to comment.