use image instead of destop
This commit is contained in:
parent
5e78ed790b
commit
c2bf9d9f00
@ -18,34 +18,34 @@ def date_string(symbols=True):
|
|||||||
return(date_str)
|
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)))
|
shutil.move(image, "{0}.png".format(date_string(False)))
|
||||||
|
|
||||||
|
|
||||||
def run_level():
|
def run_level(window):
|
||||||
"""Running level and farming apples"""
|
"""Running level and farming apples"""
|
||||||
|
|
||||||
wait("images/farm_level_on_map.png", 10)
|
window.wait("images/farm_level_on_map.png", 10)
|
||||||
click("images/farm_level_on_map.png")
|
window.click("images/farm_level_on_map.png")
|
||||||
|
|
||||||
wait("images/level_title.png", 3)
|
window.wait("images/level_title.png", 3)
|
||||||
click("images/level_start_button.png")
|
window.click("images/level_start_button.png")
|
||||||
|
|
||||||
make_screenshot()
|
make_screenshot(window)
|
||||||
|
|
||||||
wait("images/equip_window.png", 3)
|
window.wait("images/equip_window.png", 3)
|
||||||
click("images/button_start.png")
|
window.click("images/button_start.png")
|
||||||
|
|
||||||
wait("images/level_info_message.png", 5)
|
window.wait("images/level_info_message.png", 5)
|
||||||
click("images/level_info_message_ok.png")
|
window.click("images/level_info_message_ok.png")
|
||||||
|
|
||||||
Mouse.wheel(WHEEL_DOWN, 6)
|
Mouse.wheel(WHEEL_DOWN, 6)
|
||||||
|
|
||||||
pillar_heal = find("images/pillar_heal.png")
|
pillar_heal = window.find("images/pillar_heal.png")
|
||||||
pillar_fire = find("images/pillar_fire.png")
|
pillar_fire = window.find("images/pillar_fire.png")
|
||||||
|
|
||||||
for pillar in range(2):
|
for pillar in range(2):
|
||||||
pillar_fire.click("images/pillar_fire.png")
|
pillar_fire.click("images/pillar_fire.png")
|
||||||
@ -53,22 +53,22 @@ def run_level():
|
|||||||
for x in range(6):
|
for x in range(6):
|
||||||
pillar_heal.click("images/pillar_heal.png")
|
pillar_heal.click("images/pillar_heal.png")
|
||||||
|
|
||||||
click("images/pillar_go.png")
|
window.click("images/pillar_go.png")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
wait("images/winner_window.png", 60 * 2)
|
window.wait("images/winner_window.png", 60 * 2)
|
||||||
click("images/level_complete.png")
|
window.click("images/level_complete.png")
|
||||||
except FindFailed as e:
|
except FindFailed as e:
|
||||||
print("[{0}] Level timeout. Return to Map".format(date_string()))
|
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"""
|
"""Return to Map if an error has passed"""
|
||||||
|
|
||||||
click("images/menu_button.png")
|
window.click("images/menu_button.png")
|
||||||
click("images/menu_map_button.png")
|
window.click("images/menu_map_button.png")
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -76,6 +76,9 @@ def main():
|
|||||||
|
|
||||||
print("Battlepillars Farming Bot {0} by {1}".format(__version__, __author__))
|
print("Battlepillars Farming Bot {0} by {1}".format(__version__, __author__))
|
||||||
|
|
||||||
|
App.focus("Battlepillars")
|
||||||
|
game_window = App("Battlepillars").window()
|
||||||
|
|
||||||
run_count = 0
|
run_count = 0
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
@ -87,7 +90,7 @@ def main():
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
run_level()
|
run_level(game_window)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user