forked from wrenchonline/pyAutomated
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRobot_help.py
More file actions
113 lines (104 loc) · 3.89 KB
/
Robot_help.py
File metadata and controls
113 lines (104 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# -*- coding: utf-8 -*-
import threading
import time
import Robot as rb
import queue
import data as da
import cv2
from utils import *
exitFlag = 0
# Custom Exception Class
class MyException(Exception):
pass
class MyThread (threading.Thread,rb.Robot):
def __init__(self,q):
threading.Thread.__init__(self)
rb.Robot.__init__(self)
self.Get_GameHwnd()
if isinstance(q,queue.Queue):
self.queue = q
else:
raise("参数2不是队列")
# Function that raises the custom exception
def someFunction(self,):
name = threading.current_thread().name
raise MyException(self.exc)
#检测是否属于战斗状态
def check_fire(self):
status = self.Found_do(da.utils["检测战斗"]["基点"],da.utils["检测战斗"]["偏移"], 90,8,139, 84,223,ischlik=0,name="检测战斗",timeout=2)
if status != status.OK:
return False
else:
return True
#检测宝宝是否健康
def check_thePetHealth(self):
while True:
status,ag= self.findMultiColorInRegionFuzzyByTable(da.check_pet_HP)
if status == State.NOTMATCH:
self.click(1575,14)
time.sleep(1)
self.click(1224,156)
else:
break
#开始战斗
def fire(self):
#bfired = False
while True:
status = self.Found_do(da.utils["自动战斗"]["基点"],da.utils["自动战斗"]["偏移"], 92, 1202,653,1254,710,ischlik=0,name="自动战斗",timeout=1)
if status != status.OK:
break
else:
print("发现自动战斗")
#bfired = True
self.click(1230,662)
print("点击自动战斗")
time.sleep(5)
continue
def run(self):
# Variable that stores the exception, if raised by someFunction
self.exc = None
fire_end = False
try:
while True:
if not self.queue.empty(): # 如果还有队列数据
data = self.queue.get(False)
if data in "check":
while True:
bfire = self.check_fire()
if bfire:
time.sleep(1)
self.fire()
fire_end = True
print("正在战斗")
else:
while fire_end:
print("战斗结束")
self.click(1104,589)
break
if fire_end:
break
self.queue.task_done()
if data in "exit":
print("退出监控员")
self.queue.task_done()
break
else:
time.sleep(5)
#检查安全令牌
# status,x,y=self.findMultiColorInRegionFuzzy(da.prompt_box["弹出令牌界面"]["基点"],da.prompt_box["弹出令牌界面"]["偏移"],80,1213,502, 1264,561)
# if status==status.NOTMATCH:
# pass
# else:
# print("检测到安全提示框弹出,正在关闭....")
# cancel_safe_x = 1213 + x
# cancel_safe_y = 502 + y
# self.click(cancel_safe_x,cancel_safe_y)
# time.sleep(0.5)
# time.sleep(2)
except BaseException as e:
self.exc = e
self.someFunction()
def join(self):
threading.Thread.join(self)
if self.exc:
raise self.exc