dungeon.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import cv2
  2. import time
  3. from helper import (
  4. tap,
  5. look_for_templates,
  6. find_template,
  7. capture_current_screen,
  8. )
  9. # templates
  10. templates = {
  11. "to_battle": cv2.imread("templates/dungeon/to_battle2.png"),
  12. "attack": cv2.imread("templates/dungeon/attack.png"),
  13. "water": cv2.imread("templates/dungeon/water.png"),
  14. "mixed": cv2.imread("templates/dungeon/mixed.png"),
  15. "earth": cv2.imread("templates/dungeon/earth.png"),
  16. "auto_battle": cv2.imread("templates/dungeon/auto_battle.png"),
  17. "ok": cv2.imread("templates/dungeon/ok.png"),
  18. "lock": cv2.imread("templates/dungeon/lock.png"),
  19. "collect": cv2.imread("templates/dungeon/collect.png"),
  20. }
  21. print("watching the screen...")
  22. while True:
  23. time.sleep(0.5) # Polling interval
  24. capture_current_screen()
  25. name, locations = look_for_templates(templates)
  26. if name is not None:
  27. if name in ["to_battle", "auto_battle", "ok", "lock", "collect"]:
  28. tap(*locations[0])
  29. if name in ["auto_battle"]:
  30. time.sleep(0.5)
  31. if name == "attack" and len(locations) == 1:
  32. tap(*locations[0])
  33. if name == "attack" and len(locations) == 2:
  34. element = find_template(templates["mixed"])
  35. if len(element) == 0:
  36. element = find_template(templates["water"])
  37. if len(element) == 0:
  38. element = find_template(templates["earth"])
  39. tap(element[0][0], locations[0][1])