return to map by level timeout

This commit is contained in:
Alexander Popov 2022-12-26 21:23:27 +03:00
parent ac411136e9
commit 0ea5e2da0e
3 changed files with 27 additions and 9 deletions

View File

@ -5,8 +5,16 @@ __version__ = "1.0.0"
__license__ = "Unlicense" __license__ = "Unlicense"
def runLevel(): def date_string():
"""Running level and farming applesю""" """Return current date."""
date_now = datetime.now()
date_str = date_now.strftime("%Y-%m-%d %H:%M:%S")
return(date_str)
def run_level():
"""Running level and farming apples"""
wait("images/farm_level_on_map.png", 10) wait("images/farm_level_on_map.png", 10)
click("images/farm_level_on_map.png") click("images/farm_level_on_map.png")
@ -33,8 +41,20 @@ def runLevel():
click("images/pillar_go.png") click("images/pillar_go.png")
wait("images/winner_window.png", 60 * 3) try:
wait("images/winner_window.png", 60 * 2)
click("images/level_complete.png") click("images/level_complete.png")
except FindFailed as e:
print("[{0}] Level timeout. Return to Map".format(date_string()))
return_to_menu()
def return_to_menu():
"""Return to Map if an error has passed"""
click("images/menu_button.png")
click("images/menu_map_button.png")
def main(): def main():
@ -43,19 +63,17 @@ def main():
print("Battlepillars Farming Bot {0} by {1}".format(__version__, __author__)) print("Battlepillars Farming Bot {0} by {1}".format(__version__, __author__))
run_count = 0 run_count = 0
while True: while True:
run_count += 1 run_count += 1
date_now = datetime.now()
date_string = date_now.strftime("%Y-%m-%d %H:%M:%S")
print( print(
"[{date}] Running farm {times} times".format( "[{date}] Running farm {times} times".format(
date=date_string, times=run_count date=date_string(), times=run_count
) )
) )
runLevel() run_level()
if __name__ == "__main__": if __name__ == "__main__":

BIN
images/menu_button.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

BIN
images/menu_map_button.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB