|
@@ -0,0 +1,42 @@
|
|
|
|
|
+import cv2
|
|
|
|
|
+import time
|
|
|
|
|
+from helper import (
|
|
|
|
|
+ tap,
|
|
|
|
|
+ look_for_templates,
|
|
|
|
|
+ find_template,
|
|
|
|
|
+ capture_current_screen,
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+# templates
|
|
|
|
|
+templates = {
|
|
|
|
|
+ "to_battle": cv2.imread("templates/dungeon/to_battle2.png"),
|
|
|
|
|
+ "attack": cv2.imread("templates/dungeon/attack.png"),
|
|
|
|
|
+ "water": cv2.imread("templates/dungeon/water.png"),
|
|
|
|
|
+ "mixed": cv2.imread("templates/dungeon/mixed.png"),
|
|
|
|
|
+ "earth": cv2.imread("templates/dungeon/earth.png"),
|
|
|
|
|
+ "auto_battle": cv2.imread("templates/dungeon/auto_battle.png"),
|
|
|
|
|
+ "ok": cv2.imread("templates/dungeon/ok.png"),
|
|
|
|
|
+ "lock": cv2.imread("templates/dungeon/lock.png"),
|
|
|
|
|
+ "collect": cv2.imread("templates/dungeon/collect.png"),
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+print("watching the screen...")
|
|
|
|
|
+while True:
|
|
|
|
|
+ time.sleep(0.5) # Polling interval
|
|
|
|
|
+ capture_current_screen()
|
|
|
|
|
+
|
|
|
|
|
+ name, locations = look_for_templates(templates)
|
|
|
|
|
+ if name is not None:
|
|
|
|
|
+ if name in ["to_battle", "auto_battle", "ok", "lock", "collect"]:
|
|
|
|
|
+ tap(*locations[0])
|
|
|
|
|
+ if name in ["auto_battle"]:
|
|
|
|
|
+ time.sleep(0.5)
|
|
|
|
|
+ if name == "attack" and len(locations) == 1:
|
|
|
|
|
+ tap(*locations[0])
|
|
|
|
|
+ if name == "attack" and len(locations) == 2:
|
|
|
|
|
+ element = find_template(templates["mixed"])
|
|
|
|
|
+ if len(element) == 0:
|
|
|
|
|
+ element = find_template(templates["water"])
|
|
|
|
|
+ if len(element) == 0:
|
|
|
|
|
+ element = find_template(templates["earth"])
|
|
|
|
|
+ tap(element[0][0], locations[0][1])
|