use image instead of destop

This commit is contained in:
Alexander Popov 2022-12-26 21:51:36 +03:00
parent 5e78ed790b
commit c2bf9d9f00

View File

@ -18,34 +18,34 @@ def date_string(symbols=True):
return(date_str)
def make_screenshot():
"""..."""
def make_screenshot(window):
"""Save window capture for stats"""
image = capture(App.focusedWindow())
image = capture(window)
shutil.move(image, "{0}.png".format(date_string(False)))
def run_level():
def run_level(window):
"""Running level and farming apples"""
wait("images/farm_level_on_map.png", 10)
click("images/farm_level_on_map.png")
window.wait("images/farm_level_on_map.png", 10)
window.click("images/farm_level_on_map.png")
wait("images/level_title.png", 3)
click("images/level_start_button.png")
window.wait("images/level_title.png", 3)
window.click("images/level_start_button.png")
make_screenshot()
make_screenshot(window)
wait("images/equip_window.png", 3)
click("images/button_start.png")
window.wait("images/equip_window.png", 3)
window.click("images/button_start.png")
wait("images/level_info_message.png", 5)
click("images/level_info_message_ok.png")
window.wait("images/level_info_message.png", 5)
window.click("images/level_info_message_ok.png")
Mouse.wheel(WHEEL_DOWN, 6)
pillar_heal = find("images/pillar_heal.png")
pillar_fire = find("images/pillar_fire.png")
pillar_heal = window.find("images/pillar_heal.png")
pillar_fire = window.find("images/pillar_fire.png")
for pillar in range(2):
pillar_fire.click("images/pillar_fire.png")
@ -53,22 +53,22 @@ def run_level():
for x in range(6):
pillar_heal.click("images/pillar_heal.png")
click("images/pillar_go.png")
window.click("images/pillar_go.png")
try:
wait("images/winner_window.png", 60 * 2)
click("images/level_complete.png")
window.wait("images/winner_window.png", 60 * 2)
window.click("images/level_complete.png")
except FindFailed as e:
print("[{0}] Level timeout. Return to Map".format(date_string()))
return_to_menu()
return_to_menu(window)
def return_to_menu():
def return_to_menu(window):
"""Return to Map if an error has passed"""
click("images/menu_button.png")
click("images/menu_map_button.png")
window.click("images/menu_button.png")
window.click("images/menu_map_button.png")
def main():
@ -76,6 +76,9 @@ def main():
print("Battlepillars Farming Bot {0} by {1}".format(__version__, __author__))
App.focus("Battlepillars")
game_window = App("Battlepillars").window()
run_count = 0
while True:
@ -87,7 +90,7 @@ def main():
)
)
run_level()
run_level(game_window)
if __name__ == "__main__":