|
@@ -1,169 +1,113 @@
|
1
|
1
|
import cv2
|
2
|
2
|
import time
|
3
|
3
|
import pyautogui
|
4
|
|
-import subprocess
|
5
|
4
|
|
6
|
5
|
def find(image):
|
7
|
|
- #print(f"\n{image} |")
|
8
|
6
|
template = cv2.imread("assets/{}".format(image), 0)
|
9
|
7
|
width, height = template.shape[::-1]
|
10
|
|
- # pyautogui.screenshot("screenshot.png")
|
11
|
8
|
screen = cv2.imread("screenshot.png", 0)
|
12
|
9
|
width2, height2 = screen.shape[::-1]
|
13
|
|
- #print(f"Breite: {width} | Höhe: {height}\nBreite: {width2} | Höhe: {height2}")
|
|
10
|
+ # print(f"Breite: {width} | Höhe: {height}\nBreite: {width2} | Höhe: {height2}")
|
14
|
11
|
match = cv2.matchTemplate(screen, template, cv2.TM_CCOEFF_NORMED)
|
15
|
12
|
value, location = cv2.minMaxLoc(match)[1], cv2.minMaxLoc(match)[3]
|
16
|
|
- print(f"{image} | {value}")
|
17
|
|
- if (value >= 0.8):
|
|
13
|
+ if (value >= 0.85):
|
|
14
|
+ print(f"{image} | {value}")
|
18
|
15
|
return (location[0], location[1], width, height, value)
|
19
|
16
|
else:
|
20
|
17
|
return None
|
21
|
18
|
|
22
|
|
-# Event Start 950 260
|
23
|
|
-
|
24
|
|
-def startgame():
|
25
|
|
- try:
|
26
|
|
- subprocess.run("C:\\Program Files (x86)\\Steam\\steamapps\\common\\Yu-Gi-Oh! Duel Links")
|
27
|
|
- except Exception as e:
|
28
|
|
- raise e
|
29
|
|
- restart() # Starts the Event
|
30
|
|
-
|
31
|
|
-
|
32
|
|
-
|
33
|
|
-def restart():
|
34
|
|
- # Reboot function
|
35
|
|
- initiate = None
|
36
|
|
-
|
37
|
|
- while initiate == None:
|
|
19
|
+def autoduelloop():
|
|
20
|
+ while True:
|
38
|
21
|
time.sleep(1)
|
39
|
|
- try:
|
40
|
|
- initiate = find("Initiatelink.png")
|
41
|
|
- except:
|
42
|
|
- pass
|
43
|
|
- pyautogui.click((initiate[0], initiate[1]))
|
|
22
|
+ pyautogui.screenshot("screenshot.png")
|
44
|
23
|
|
45
|
|
- notifications = None
|
|
24
|
+ # OK Button
|
|
25
|
+ okbutton = find("ok.png")
|
|
26
|
+ if okbutton != None:
|
|
27
|
+ pyautogui.click((okbutton[0], okbutton[1]))
|
|
28
|
+ break
|
46
|
29
|
|
47
|
|
- while notifications == None:
|
48
|
|
- time.sleep(1)
|
49
|
|
- try:
|
50
|
|
- notifications = find("arrow.png")
|
51
|
|
- except:
|
52
|
|
- pass
|
53
|
|
- pyautogui.click((notifications[0], notifications[1]))
|
|
30
|
+ # Next
|
|
31
|
+ nextbutton = find("next.png")
|
|
32
|
+ if nextbutton != None:
|
|
33
|
+ pyautogui.click((nextbutton[0], nextbutton[1]))
|
|
34
|
+ break
|
54
|
35
|
|
55
|
|
- # Click Event
|
56
|
|
- pyautogui.click(950, 250)
|
|
36
|
+ # Rescue Complete
|
|
37
|
+ rescom = find("mark.png")
|
|
38
|
+ if rescom != None:
|
|
39
|
+ pyautogui.click((rescom[0], rescom[1]))
|
|
40
|
+ break
|
|
41
|
+
|
|
42
|
+ # Level Up
|
|
43
|
+ levelup = find("lvlup.png")
|
|
44
|
+ if levelup != None:
|
|
45
|
+ pyautogui.click((levelup[0], levelup[1]))
|
|
46
|
+ break
|
|
47
|
+
|
|
48
|
+ # Dialog
|
|
49
|
+ dialog = find("rndclick.png")
|
|
50
|
+ if dialog != None:
|
|
51
|
+ pyautogui.click((dialog[0], dialog[1]))
|
|
52
|
+ break
|
57
|
53
|
|
58
|
|
-count = int(0)
|
59
|
|
-while True:
|
60
|
|
- # Start
|
61
|
|
-
|
62
|
|
- #time.sleep(3)
|
63
|
|
- pyautogui.screenshot("screenshot.png")
|
64
|
|
- print(count)
|
65
|
|
- count += 1
|
66
|
|
- try:
|
67
|
|
- print(f"trsbox")
|
68
|
|
- trsbox = find("trsbox.png")
|
69
|
|
- if trsbox == None:
|
70
|
|
- pass
|
71
|
|
- else:
|
72
|
|
- pyautogui.click(950, 700)
|
73
|
|
- pyautogui.scroll(-2000, pause=1)
|
74
|
|
- # pyautogui.click((turbo[0], turbo[1]))
|
75
|
|
-
|
76
|
|
- time.sleep(0.5)
|
77
|
|
- Assist = find("assistduel.png")
|
78
|
|
- if Assist == None:
|
79
|
|
- pass
|
80
|
|
- else:
|
81
|
|
- test = pyautogui.click((Assist[0], Assist[1]))
|
82
|
|
- except:
|
83
|
|
- pass # print(f"failed")
|
84
|
|
-
|
85
|
|
-
|
86
|
|
- try:
|
87
|
|
- pass # print(f"Start Duell")
|
88
|
|
- # Assist Duel
|
89
|
|
- Assist = find("assistduel.png")
|
90
|
|
- if Assist == None:
|
91
|
|
- pass
|
92
|
|
- else:
|
93
|
|
- test = pyautogui.click((Assist[0], Assist[1]))
|
94
|
|
- except:
|
95
|
|
- pass # print(f"Start Duell nicht gefunden")
|
96
|
|
-
|
97
|
|
- try:
|
98
|
|
- Rndclick = find("rndclick.png")
|
99
|
|
- if Rndclick == None:
|
100
|
|
- pass
|
101
|
|
- else:
|
102
|
|
- pyautogui.click((Rndclick[0], Rndclick[1]))
|
103
|
|
- except:
|
104
|
|
- pass # print(f"Dialog nicht gefunden")
|
105
|
|
-
|
106
|
|
- try:
|
107
|
54
|
# Auto-Duel
|
108
|
55
|
autoduel = find("autoduel.png")
|
109
|
|
- if autoduel == None:
|
110
|
|
- pass
|
111
|
|
- else:
|
|
56
|
+ if autoduel != None:
|
112
|
57
|
pyautogui.click((autoduel[0], autoduel[1]))
|
113
|
|
- except:
|
114
|
|
- pass # print(f"Auto-Duel nicht gefunden")
|
115
|
|
-
|
116
|
|
- try:
|
117
|
|
- # Result
|
118
|
|
- NOM_OK = find("ok.png")
|
119
|
|
- if NOM_OK == None:
|
120
|
|
- pass
|
121
|
|
- else:
|
122
|
|
- pyautogui.click((NOM_OK[0], NOM_OK[1]))
|
123
|
|
- except:
|
124
|
|
- pass # print(f"Result nicht gefunden")
|
125
|
|
-
|
126
|
|
- try:
|
127
|
|
- # Rescue Complete
|
128
|
|
- RC = find("mark.png")
|
129
|
|
- if RC == None:
|
130
|
|
- pass
|
131
|
|
- else:
|
132
|
|
- pyautogui.click((RC[0], RC[1]))
|
133
|
|
- except:
|
134
|
|
- pass # print(f"Rescue Complete nicht gefunden")
|
135
|
|
-
|
136
|
|
-
|
137
|
|
- try:
|
138
|
|
- # Assisting Players
|
139
|
|
- NOM_NEXT = find("next.png")
|
140
|
|
- if NOM_NEXT == None:
|
141
|
|
- pass
|
142
|
|
- else:
|
143
|
|
- pyautogui.click((NOM_NEXT[0], NOM_NEXT[1]))
|
144
|
|
- except:
|
145
|
|
- pass
|
146
|
|
- pass # print(f"Assisting Players nicht gefunden")
|
147
|
|
-
|
148
|
|
-
|
|
58
|
+ break
|
149
|
59
|
|
|
60
|
+ # Assist Duel
|
|
61
|
+ trsbox = find("trsbox.png")
|
|
62
|
+ if trsbox != None:
|
|
63
|
+ pyautogui.scroll(-4000, pause=1)
|
|
64
|
+ pyautogui.scroll(-4000, pause=1)
|
|
65
|
+ pyautogui.screenshot("screenshot.png")
|
|
66
|
+ assist = find("assistduel.png")
|
|
67
|
+ if assist != None:
|
|
68
|
+ pyautogui.click((assist[0], assist[1]))
|
|
69
|
+ break
|
|
70
|
+
|
|
71
|
+ # Active Duel
|
|
72
|
+ duellog = find("duellog.png")
|
|
73
|
+ if duellog != None:
|
|
74
|
+ time.sleep(5)
|
|
75
|
+ break
|
150
|
76
|
|
151
|
|
- try:
|
152
|
77
|
# Reboot
|
153
|
|
- RB = find("reboot.png")
|
154
|
|
- if RB == None:
|
155
|
|
- pass
|
156
|
|
- else:
|
157
|
|
- restart()
|
158
|
|
- except:
|
159
|
|
- pass # print(f"Reboot nicht gefunden")
|
160
|
|
-
|
161
|
|
- try:
|
162
|
|
- # LVL UP
|
163
|
|
- LVL = find("lvlup.png")
|
164
|
|
- if LVL == None:
|
165
|
|
- pass
|
166
|
|
- else:
|
167
|
|
- pyautogui.click((LVL[0], LVL[1]))
|
168
|
|
- except:
|
169
|
|
- pass
|
|
78
|
+ reboot = find("reboot.png")
|
|
79
|
+ if reboot != None:
|
|
80
|
+ pyautogui.click((reboot[0], reboot[1]))
|
|
81
|
+ break
|
|
82
|
+
|
|
83
|
+ # Initiate Link
|
|
84
|
+ initiate = find("Initiatelink.png")
|
|
85
|
+ if initiate != None:
|
|
86
|
+ pyautogui.click((initiate[0], initiate[1]))
|
|
87
|
+ break
|
|
88
|
+
|
|
89
|
+ # Main Menu
|
|
90
|
+ mainmenu = find("mainmenu.png")
|
|
91
|
+ if mainmenu != None:
|
|
92
|
+ pyautogui.click((950, 280))
|
|
93
|
+ break
|
|
94
|
+
|
|
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
|
+ # End of the Loop
|
|
108
|
+ print(f"End of the Loop")
|
|
109
|
+ time.sleep(3)
|
|
110
|
+ break
|
|
111
|
+
|
|
112
|
+while True:
|
|
113
|
+ autoduelloop()
|