You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.py 3.2KB

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