98 lines
2.3 KiB
Python
98 lines
2.3 KiB
Python
from datetime import datetime
|
|
import shutil
|
|
|
|
__author__ = "Alexander Popov <iiiypuk@fastmail.fm>"
|
|
__version__ = "2.0.0"
|
|
__license__ = "Unlicense"
|
|
|
|
|
|
def date_string(symbols=True):
|
|
"""Return current date."""
|
|
date_now = datetime.now()
|
|
|
|
if symbols:
|
|
date_str = date_now.strftime("%Y-%m-%d %H:%M:%S")
|
|
else:
|
|
date_str = date_now.strftime("%Y-%m-%d_%H_%M_%S")
|
|
|
|
return(date_str)
|
|
|
|
|
|
def make_screenshot(window):
|
|
"""Save window capture for stats"""
|
|
|
|
image = capture(window)
|
|
shutil.move(image, "{0}.png".format(date_string(False)))
|
|
|
|
|
|
def run_level(window):
|
|
"""Running level and farming apples"""
|
|
|
|
window.wait("images/farm_level_on_map.png", 10)
|
|
window.click("images/farm_level_on_map.png")
|
|
|
|
window.wait("images/level_title.png", 3)
|
|
window.click("images/level_start_button.png")
|
|
|
|
make_screenshot(window)
|
|
|
|
window.wait("images/equip_window.png", 3)
|
|
window.click("images/button_start.png")
|
|
|
|
window.wait("images/level_info_message.png", 5)
|
|
window.click("images/level_info_message_ok.png")
|
|
|
|
Mouse.wheel(WHEEL_DOWN, 6)
|
|
|
|
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")
|
|
|
|
for x in range(6):
|
|
pillar_heal.click("images/pillar_heal.png")
|
|
|
|
window.click("images/pillar_go.png")
|
|
|
|
try:
|
|
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(window)
|
|
|
|
|
|
def return_to_menu(window):
|
|
"""Return to Map if an error has passed"""
|
|
|
|
window.click("images/menu_button.png")
|
|
window.click("images/menu_map_button.png")
|
|
|
|
|
|
def main():
|
|
"""Main farm loop."""
|
|
|
|
print("Battlepillars Farming Bot {0} by {1}".format(__version__, __author__))
|
|
|
|
App.focus("Battlepillars")
|
|
game_window = App("Battlepillars").window()
|
|
|
|
run_count = 0
|
|
|
|
while True:
|
|
run_count += 1
|
|
|
|
print(
|
|
"[{date}] Running farm {times} times".format(
|
|
date=date_string(), times=run_count
|
|
)
|
|
)
|
|
|
|
run_level(game_window)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|