Browse Source

error folder added

Neccor 4 years ago
parent
commit
a0ba363304
3 changed files with 34 additions and 17 deletions
  1. 1
    0
      .gitignore
  2. BIN
      assets/assistduel.png
  3. 33
    17
      main.py

+ 1
- 0
.gitignore View File

@@ -2,6 +2,7 @@
2 2
 # Custom
3 3
 screenshots/
4 4
 screenshot.png
5
+error/*
5 6
 
6 7
 # Byte-compiled / optimized / DLL files
7 8
 __pycache__/

BIN
assets/assistduel.png View File


+ 33
- 17
main.py View File

@@ -1,8 +1,16 @@
1 1
 import cv2
2 2
 import time
3 3
 import pyautogui
4
+from datetime import datetime, date
5
+from os.path import isfile, join
6
+import os
4 7
 
5
-def find(image):
8
+eol = int(0)
9
+
10
+if not os.path.exists(os.path.join(os.getcwd(), "error")):
11
+	os.path.join(os.getcwd(), "error")
12
+
13
+def find(image, coef=None):
6 14
 	template = cv2.imread("assets/{}".format(image), 0)
7 15
 	width, height = template.shape[::-1]
8 16
 	screen = cv2.imread("screenshot.png", 0)
@@ -10,15 +18,17 @@ def find(image):
10 18
 	# print(f"Breite: {width} | Höhe: {height}\nBreite: {width2} | Höhe: {height2}")
11 19
 	match = cv2.matchTemplate(screen, template, cv2.TM_CCOEFF_NORMED)
12 20
 	value, location = cv2.minMaxLoc(match)[1], cv2.minMaxLoc(match)[3]
21
+	print(f"{image} | {value}")
13 22
 	if (value >= 0.85):
14 23
 		print(f"{image} | {value}")
15 24
 		return (location[0], location[1], width, height, value)
16 25
 	else:
17 26
 		return None
18 27
 
19
-def autoduelloop():
28
+def autoduelloop(eol):
20 29
 	while True:
21 30
 		time.sleep(1)
31
+		print(f"\n")
22 32
 		pyautogui.screenshot("screenshot.png")
23 33
 
24 34
 		# OK Button
@@ -57,11 +67,18 @@ def autoduelloop():
57 67
 			pyautogui.click((autoduel[0], autoduel[1]))
58 68
 			break
59 69
 
70
+		# Close
71
+		close = find("close.png")
72
+		if close != None:
73
+			pyautogui.click((close[0], close[1]))
74
+			break
75
+
60 76
 		# Assist Duel
61 77
 		trsbox = find("trsbox.png")
62 78
 		if trsbox != None:
63 79
 			pyautogui.scroll(-4000, pause=1)
64 80
 			pyautogui.scroll(-4000, pause=1)
81
+			time.sleep(1)
65 82
 			pyautogui.screenshot("screenshot.png")
66 83
 		assist = find("assistduel.png")
67 84
 		if assist != None:
@@ -92,22 +109,21 @@ def autoduelloop():
92 109
 			pyautogui.click((950, 280))
93 110
 			break
94 111
 
95
-		# Arrow
96
-		arrow = find("arrow.png")
97
-		if arrow != None:
98
-			pyautogui.click((arrow[0], arrow[1]))
99
-			break
100
-
101
-		# Close
102
-		close = find("close.png")
103
-		if close != None:
104
-			pyautogui.click((close[0], close[1]))
105
-			break
106
-
107 112
 		# End of the Loop
108
-		print(f"End of the Loop")
109
-		time.sleep(3)
113
+		print(f"End of the Loop | EOL: {eol}")
114
+		time.sleep(0)
115
+		if eol >= 5:
116
+			# Arrow
117
+			arrow = find("arrow.png")
118
+			if arrow != None:
119
+				pyautogui.click((arrow[0], arrow[1]))
120
+				break
110 121
 		break
111 122
 
112 123
 while True:
113
-	autoduelloop()
124
+	autoduelloop(eol)
125
+	eol += 1
126
+	if eol >= 10:
127
+		time.sleep(1)
128
+		eol = int(0)
129
+		pyautogui.screenshot(f"error/error-{datetime.now().strftime('%Y-%m-%d-%H-%M')}.png")

Loading…
Cancel
Save