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 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import cv2
  2. import time
  3. import pyautogui
  4. from datetime import datetime, date
  5. eol = int(0)
  6. def find(image, coef=None):
  7. template = cv2.imread("assets/{}".format(image), 0)
  8. width, height = template.shape[::-1]
  9. screen = cv2.imread("screenshot.png", 0)
  10. width2, height2 = screen.shape[::-1]
  11. match = cv2.matchTemplate(screen, template, cv2.TM_CCOEFF_NORMED)
  12. value, location = cv2.minMaxLoc(match)[1], cv2.minMaxLoc(match)[3]
  13. if image == "assistduel.png":
  14. print(f"Val: {value} | {image}")
  15. if (value >= 0.8):
  16. print(f"Val: {value} | {image}")
  17. return (location[0], location[1], width, height, value)
  18. else:
  19. return None
  20. def autoduelloop(eol):
  21. while True:
  22. time.sleep(1)
  23. pyautogui.screenshot("screenshot.png")
  24. # OK Button
  25. okbutton = find("ok.png")
  26. if okbutton != None:
  27. pyautogui.click((okbutton[0], okbutton[1]))
  28. break
  29. # Next
  30. nextbutton = find("next.png")
  31. if nextbutton != None:
  32. pyautogui.click((nextbutton[0], nextbutton[1]))
  33. break
  34. # Rescue Complete
  35. rescom = find("mark.png")
  36. if rescom != None:
  37. pyautogui.click((rescom[0], rescom[1]))
  38. break
  39. # Level Up
  40. levelup = find("lvlup.png")
  41. if levelup != None:
  42. pyautogui.click((levelup[0], levelup[1]))
  43. break
  44. # Dialog
  45. dialog = find("rndclick.png")
  46. if dialog != None:
  47. pyautogui.click((dialog[0], dialog[1]))
  48. break
  49. # Auto-Duel
  50. autoduel = find("autoduel.png")
  51. if autoduel != None:
  52. pyautogui.click((autoduel[0], autoduel[1]))
  53. break
  54. # Close
  55. close = find("close.png")
  56. if close != None:
  57. pyautogui.click((close[0], close[1]))
  58. break
  59. # Assist Duel
  60. assist = find("assistduel.png")
  61. if assist != None:
  62. pyautogui.click((assist[0], assist[1]))
  63. break
  64. trsbox = find("trsbox.png")
  65. if trsbox != None:
  66. pyautogui.scroll(-4000, pause=1)
  67. pyautogui.scroll(-4000, pause=1)
  68. time.sleep(1)
  69. pyautogui.screenshot("screenshot.png")
  70. assist = find("assistduel.png")
  71. if assist != None:
  72. pyautogui.click((assist[0], assist[1]))
  73. break
  74. # Active Duel
  75. duellog = find("duellog.png")
  76. if duellog != None:
  77. time.sleep(5)
  78. break
  79. # Reboot
  80. reboot = find("reboot.png")
  81. if reboot != None:
  82. pyautogui.click((reboot[0], reboot[1]))
  83. break
  84. # Initiate Link
  85. initiate = find("Initiatelink.png")
  86. if initiate != None:
  87. pyautogui.click((initiate[0], initiate[1]))
  88. break
  89. # Main Menu
  90. mainmenu = find("mainmenu.png")
  91. if mainmenu != None:
  92. pyautogui.click((950, 280))
  93. break
  94. # End of the Loop
  95. print(f"End of the Loop | EOL: {eol}")
  96. time.sleep(3)
  97. if eol >= 5:
  98. # Arrow
  99. arrow = find("arrow.png")
  100. if arrow != None:
  101. pyautogui.click((arrow[0], arrow[1]))
  102. break
  103. break
  104. while True:
  105. autoduelloop(eol)
  106. eol += 1
  107. if eol == 10:
  108. pyautogui.click((950, 280))
  109. elif eol >= 15:
  110. time.sleep(1)
  111. eol = int(0)
  112. pyautogui.screenshot(f"error/error-{datetime.now().strftime('%Y-%m-%d-%H-%M')}.png")