refactor dig
This commit is contained in:
147
digging_main2.py
Normal file
147
digging_main2.py
Normal file
@@ -0,0 +1,147 @@
|
||||
from config_file import UserConfigs
|
||||
import keyboard
|
||||
from utils import dig_point, check_for_ok_button
|
||||
from window_capture import WindowCapture
|
||||
from vision import Vision
|
||||
|
||||
def run():
|
||||
# initialize the user-class
|
||||
config = UserConfigs()
|
||||
# initialize the StunWindowCapture class
|
||||
capture_config = UserConfigs()
|
||||
capture_window = WindowCapture(None, "screen_conf", capture_config)
|
||||
# initialize the StunVision class
|
||||
vision_stun = Vision()
|
||||
|
||||
|
||||
|
||||
pause = True
|
||||
level = 1
|
||||
|
||||
width = 32
|
||||
depth = 24
|
||||
plot_size = 47
|
||||
DIG_TIME = 150
|
||||
|
||||
while True:
|
||||
if keyboard.is_pressed('p') == True:
|
||||
pause = True
|
||||
print('q pressed')
|
||||
elif keyboard.is_pressed('o') == True:
|
||||
pause = False
|
||||
print('o pressed')
|
||||
if pause:
|
||||
# cv.waitKey(500)
|
||||
print("pausing")
|
||||
continue
|
||||
|
||||
if level == 3:
|
||||
plot_size = 45
|
||||
width = 30
|
||||
elif level == 5:
|
||||
plot_size = 43
|
||||
width = 28
|
||||
elif level == 7:
|
||||
plot_size = 41
|
||||
width = 26
|
||||
elif level == 9:
|
||||
plot_size = 39
|
||||
elif level == 11:
|
||||
plot_size = 37
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
p1 = int((config.returnDiggingWindowPos2()[0] / 2) + config.returnDiggingWindowPos2()[2])
|
||||
p2 = int((config.returnDiggingWindowPos2()[1] / 2) + config.returnDiggingWindowPos2()[3])
|
||||
|
||||
|
||||
|
||||
# start 705 , 564 -> click
|
||||
# move L D -> click
|
||||
# move U , U , R, R , D , D , L , L
|
||||
# move L D
|
||||
# move U , U , U , U , R, R , R, R, D, D, D, D, L, L, L , L
|
||||
dig_point(p1, p2, DIG_TIME)
|
||||
#cv.circle(screenshot, (p1, p2), 7, (0, 255, 0), -1)
|
||||
i = 0
|
||||
for e in range(2, width, 2):
|
||||
i = i + 1
|
||||
|
||||
tp1 = p1 - (i * plot_size)
|
||||
tp2 = p2 + (i * plot_size)
|
||||
for f in range(0, e, 1):
|
||||
# up click
|
||||
tp2 = tp2 - plot_size
|
||||
if tp2 >= config.returnDiggingWindowPos2()[1] + plot_size:
|
||||
continue
|
||||
if tp2 <= config.returnDiggingWindowPos2()[3] + plot_size:
|
||||
continue
|
||||
|
||||
dig_point(tp1, tp2, DIG_TIME)
|
||||
#cv.circle(screenshot, (tp1, tp2), 7, (255, 0, 255), -1)
|
||||
#cv.imshow("screenshot", screenshot)
|
||||
#cv.waitKey(150)
|
||||
check_for_ok_button(capture_window, vision_stun, capture_config)
|
||||
if keyboard.is_pressed('p') == True or pause == True:
|
||||
pause = True
|
||||
break
|
||||
|
||||
tp1 = p1 - (i * plot_size)
|
||||
tp2 = p2 - (i * plot_size)
|
||||
for g in range(0, e, 1):
|
||||
# right click
|
||||
tp1 = tp1 + plot_size
|
||||
if tp2 <= config.returnDiggingWindowPos2()[3] + plot_size:
|
||||
continue
|
||||
dig_point(tp1, tp2, DIG_TIME)
|
||||
#cv.circle(screenshot, (tp1, tp2), 7, (127, 0, 255), -1)
|
||||
#cv.imshow("screenshot", screenshot)
|
||||
#cv.waitKey(150)
|
||||
check_for_ok_button(capture_window, vision_stun, capture_config)
|
||||
if keyboard.is_pressed('p') == True or pause == True:
|
||||
pause = True
|
||||
break
|
||||
|
||||
tp1 = p1 + (i * plot_size)
|
||||
tp2 = p2 - (i * plot_size)
|
||||
for r in range(0, e, 1):
|
||||
# down click
|
||||
tp2 = tp2 + plot_size
|
||||
if tp2 >= config.returnDiggingWindowPos2()[1] + plot_size:
|
||||
continue
|
||||
if tp2 <= config.returnDiggingWindowPos2()[3] + plot_size:
|
||||
continue
|
||||
dig_point(tp1, tp2, DIG_TIME)
|
||||
#cv.circle(screenshot, (tp1, tp2), 7, (255, 0, 127), -1)
|
||||
#cv.imshow("screenshot", screenshot)
|
||||
#cv.waitKey(150)
|
||||
check_for_ok_button(capture_window, vision_stun, capture_config)
|
||||
if keyboard.is_pressed('p') == True or pause == True:
|
||||
pause = True
|
||||
break
|
||||
|
||||
tp1 = p1 + (i * plot_size)
|
||||
tp2 = p2 + (i * plot_size)
|
||||
for u in range(0, e, 1):
|
||||
# left click
|
||||
tp1 = tp1 - plot_size
|
||||
if tp2 >= config.returnDiggingWindowPos2()[1] + plot_size:
|
||||
continue
|
||||
dig_point(tp1, tp2, DIG_TIME)
|
||||
#cv.circle(screenshot, (tp1, tp2), 7, (0, 0, 255), -1)
|
||||
#cv.imshow("screenshot", screenshot)
|
||||
#cv.waitKey(150)
|
||||
check_for_ok_button(capture_window, vision_stun, capture_config)
|
||||
if keyboard.is_pressed('p') == True or pause == True:
|
||||
pause = True
|
||||
break
|
||||
if keyboard.is_pressed('p') == True or pause == True:
|
||||
pause = True
|
||||
break
|
||||
if keyboard.is_pressed('p') == True or pause == True:
|
||||
pause = True
|
||||
break
|
||||
level = level +1
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
Reference in New Issue
Block a user