forked from wrenchonline/pyAutomated
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
2302 lines (2164 loc) · 80 KB
/
main.py
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
import Robot as rb
import time
from utils import *
import Robot_help as rh
import math
import queue
import json
import os
import data as da
utils_list = [
da.utils["飞行符"],
da.utils["红旗"],
da.utils["绿旗"],
da.utils["黄旗"],
da.utils["白旗"],
da.utils["红罗羹"],
da.utils["绿芦羹"],
da.utils["摄妖香"]
]
class action(rb.Robot):
def __init__(self,q):
rb.Robot.__init__(self)
self.Get_GameHwnd()
self.cx = None
self.error = list()
if isinstance(q,queue.Queue):
self.queue = q
else:
raise("参数2不是队列")
def flag_transfer(self,color):
time.sleep(0.5)
self.click(653,132)
time.sleep(0.5)
while True:
if color == "red":
status = self.Found_do(da.utils["红旗"]["基点"],da.utils["红旗"]["偏移"], 70,592,170, 1057,538,ischlik=2,name="红旗")
if status == status.OK:
break
elif color == "yellow":
status = self.Found_do(da.utils["黄旗"]["基点"],da.utils["黄旗"]["偏移"], 70,592,170, 1057,538,ischlik=2,name="黄旗")
if status == status.OK:
break
elif color == "blue":
status = self.Found_do(da.utils["蓝旗"]["基点"],da.utils["蓝旗"]["偏移"], 70,592,170, 1057,538,ischlik=2,name="蓝旗")
if status == status.OK:
break
elif color == "green":
status = self.Found_do(da.utils["绿旗"]["基点"],da.utils["绿旗"]["偏移"], 70,592,170, 1057,538,ischlik=2,name="绿旗")
if status == status.OK:
break
elif color == "white":
status = self.Found_do(da.utils["白旗"]["基点"],da.utils["白旗"]["偏移"], 70,592,170, 1057,538,ischlik=2,name="白旗")
if status == status.OK:
break
else:
#没找到,去行囊里面找
self.click(833,140)
time.sleep(0.5)
while True:
if color == "red":
status = self.Found_do(da.utils["红旗"]["基点"],da.utils["红旗"]["偏移"], 70,592,170, 1057,538,ischlik=2,name="红旗")
if status == status.OK:
cbreakon
elif color == "yellow":
status = self.Found_do(da.utils["黄旗"]["基点"],da.utils["黄旗"]["偏移"], 70,592,170, 1057,538,ischlik=3,name="黄旗")
if status == status.OK:
break
elif color == "blue":
status = self.Found_do(da.utils["蓝旗"]["基点"],da.utils["蓝旗"]["偏移"], 70,592,170, 1057,538,ischlik=3,name="蓝旗")
if status == status.OK:
break
elif color == "green":
status = self.Found_do(da.utils["绿旗"]["基点"],da.utils["绿旗"]["偏移"], 70,592,170, 1057,538,ischlik=3,name="绿旗")
if status == status.OK:
break
elif color == "white":
status = self.Found_do(da.utils["白旗"]["基点"],da.utils["白旗"]["偏移"], 70,592,170, 1057,538,ischlik=3,name="白旗")
if status == status.OK:
break
else:
print("not found flags")
return State.NOTMATCH
continue
return State.OK
def run_with_callback(self,fun,fun_param,pre_fun1,fun1_param,post_fun2,fun2_param):
try:
print("start pre_fun1")
ret = pre_fun1(fun_param)
ret = fun(ret,fun1_param)
ret = post_fun2(ret,fun2_param)
self.cx = ret
except Exception as identifier:
self.error.append(identifier)
#测试保存物品
def save_the_prize(self):
self.find_items()
#
def map_items(self,convert_pos:list,da_items:dict):
time.sleep(0.1)
#print("check items_name:{0}".format(da_items["物品名"]))
_,x,y = self.findMultiColorInRegionFuzzy(da_items["基点"], da_items["偏移"], 85, convert_pos[0], convert_pos[1], convert_pos[2], convert_pos[3])
if x != -1:
print("found items_name:{0} x:{1} y:{2}".format(da_items["物品名"],x,y))
return True
else: return False
'''
发现道具栏物品,如果是非识别物品,先存入仓库中
'''
def find_items(self):
self.ToTheXLNG()
time.sleep(0.5)
self.mask_(True)
time.sleep(1)
status = self.Found_do(da.utils["西梁仓库管理员"]["基点"],da.utils["西梁仓库管理员"]["偏移"],
80,0, 0,1279,719,
ischlik=2,timeout=10,
name="西梁仓库管理员")
if status == State.NOTMATCH:
raise
time.sleep(1)
while True:
if self.rgb_array(da.cangku["仓库操作"])==State.OK:
self.click(1017,424)
break
else:
time.sleep(0.5)
while True:
if self.rgb_array(da.cangku["仓库界面"])==State.OK:
break
start_pos = ( 625,213,708,279)
convert_pos = [ 625,213,708,279]
for i in range(0,5):
time.sleep(1)
convert_pos[0] = start_pos[0] + i*90
convert_pos[2] = start_pos[2] + i*90
for j in range(0,4):
time.sleep(1)
convert_pos[1] = start_pos[1] + j*90
convert_pos[3] = start_pos[3] + j*90
self.click(convert_pos[0]+5,convert_pos[1]+5)
timc = [convert_pos[0],convert_pos[1],convert_pos[2],convert_pos[3]]
# tpl = self.Print_screen()
# self.show(tpl[convert_pos[1]:convert_pos[3],convert_pos[0]:convert_pos[2]])
#发现的物品
items_name_list = map(self.map_items,[timc for i in range (len(utils_list))],utils_list)
tmp = [b for b in items_name_list]
if True in tmp:
continue
else:
#print("double click on the items bar i:{0} j:{1}".format(i,j))
while True:
self.click(convert_pos[0]+5,convert_pos[1]+5)
self.click(convert_pos[0]+5,convert_pos[1]+5)
_x1 = convert_pos[0]+int((convert_pos[2]-convert_pos[0])/2)
_y1 = convert_pos[1]+int((convert_pos[3]-convert_pos[1])/2)
status,ag= self.findMultiColorInRegionFuzzyByTable(((_x1,_y1,0xb8b0d8),))
# status = self.Found_do(da.utils["道具栏空白"]["基点"],da.utils["道具栏空白"]["偏移"],
# 100,convert_pos[0], convert_pos[1], convert_pos[2], convert_pos[3],
# ischlik=2,timeout=1,
# name="道具栏空白")
if status == status.OK:
break
else:
time.sleep(1.5)
print("the blank items is not Found")
self.click(366,621)
time.sleep(1.5)
self.click(convert_pos[0]+5,convert_pos[1]+5)
self.click(convert_pos[0]+5,convert_pos[1]+5)
continue
print("退出到主界面")
while True:
status,ag= self.findMultiColorInRegionFuzzyByTable(da.zhujiemian)
if status==status.NOTMATCH:
self.click(1075,59)
time.sleep(1.5)
else:
break
'''
在各主城增加了仓库管理员NPC,坐标分别为:长安城(346,244)、长安城(224,141)、建邺城(54,32)、傲来国(143,101)、长寿村(111,62)、朱紫国(126,90)
'''
#check_map 打开道具栏遍历宝图
def check_map(self):
#打开道具栏
while True:
#self.queue.put("check")
if self.no_prop():
self.click(1220, 679)
time.sleep(0.5)
if not self.no_prop():
break
else:
break
time.sleep(2)
self.click(1121, 673)
time.sleep(1)
# tpl = self.Print_screen()
# target = cv2.imread("./images/tu.png")
start_pos = (600,175,683,257)
convert_pos = [600,175,683,257]
tu_list = list()
for i in range(0,5):
time.sleep(0.5)
convert_pos[0] = start_pos[0] + i*90
convert_pos[2] = start_pos[2] + i*90
for j in range(0,4):
time.sleep(0.5)
print(j)
convert_pos[1] = start_pos[1] + j*90
convert_pos[3] = start_pos[3] + j*90
self.click(convert_pos[0]+5,convert_pos[1]+5)
time.sleep(0.5)
tpl = self.Print_screen()
#self.show(tpl[convert_pos[1]:convert_pos[3],convert_pos[0]:convert_pos[2]])
_,x,y = self.findMultiColorInRegionFuzzy( da.daoju["普通宝图A"]["基点"], da.daoju["普通宝图A"]["偏移"], 45, convert_pos[0], convert_pos[1], convert_pos[2], convert_pos[3])
#self.show(tpl[convert_pos[1]:convert_pos[3],convert_pos[0]:convert_pos[2]])
# x,y = self.matchTemplate(tpl[convert_pos[1]:convert_pos[3],convert_pos[0]:convert_pos[2]],target,0.13)
if x != -1:
print("找到宝图")
while True:
if self.rgb_array(da.ditu_show["道具栏显示地图字体"]) == State.OK:
break
else:
time.sleep(1)
#检测字体
data = self.x_Ocrtext(da.ditu,"00E804,011805#03DC07,032006#08DD0B,072009",297,338,394,366,similarity=0.5)
print(data)
if data:
if len(data)>3:
pos = self.Ocrtext(da.map_font,"06BE0B,06420B#03E105,031E05#00E804,011805#03DC07,032006#08DD0B,072009"
,401,343,485,364,M=0.2)
print("postr:",pos)
if len(pos):
if pos[0] == "?":
pos = pos[1:]
if pos[len(pos)-1]=="?":
pos = pos[:len(pos)-1]
postr = pos.replace("\n","")
postr = pos.replace("??","?")
try:
_x = int(postr.split('?')[0])
_y = int(postr.split('?')[1])
tu_list.append((data,_x,_y,convert_pos[0]+5,convert_pos[1]+5,convert_pos[2],convert_pos[3]))
except Exception as e:
print("字库解析异常")
else:
pos = self.Ocrtext(da.map_font,"06BE0B,06420B#03E105,031E05#00E804,011805#03DC07,032006#08DD0B,072009"
,370,339,485,364,M=0.2)
print("postr:",pos)
if len(pos):
if pos[0] == "?":
pos = pos[1:]
if pos[len(pos)-1]=="?":
pos = pos[:len(pos)-1]
postr = pos.replace("\n","")
postr = pos.replace("??","?")
try:
_x = int(postr.split('?')[0])
_y = int(postr.split('?')[1])
tu_list.append((data,_x,_y,convert_pos[0]+5,convert_pos[1]+5,convert_pos[2],convert_pos[3]))
except Exception as e:
print("字库解析异常")
return tu_list
#前往长寿村
def go_to_CSC(self):
while True:
#self.queue.put("check")
status,ag= self.findMultiColorInRegionFuzzyByTable(da.feixingfu_jiemian)
if status==status.OK:
time.sleep(0.7)
self.click(512,202)
time.sleep(0.7)
break
while True:
#self.queue.put("check")
status,ag= self.findMultiColorInRegionFuzzyByTable(da.zhujiemian)
time.sleep(0.5)
if status==status.NOTMATCH:
print("前往长寿村")
status,ag= self.findMultiColorInRegionFuzzyByTable(da.fanhui)
if status==status.OK:
self.click(ag[0],ag[1])
time.sleep(0.5)
elif status==status.OK:
print("抵达长寿村")
break
return True
#TAPP 计算坐标
def TAPP(self,D,xx,yy):
rx = da.Table_梦幻[D]["坐标计算"][0] + (((da.Table_梦幻[D]["坐标计算"][2] - da.Table_梦幻[D]["坐标计算"][0]) / da.Table_梦幻[D]["坐标计算"][4]) * xx+0)
ry = da.Table_梦幻[D]["坐标计算"][3] - (((da.Table_梦幻[D]["坐标计算"][3] - da.Table_梦幻[D]["坐标计算"][1]) / da.Table_梦幻[D]["坐标计算"][5]) * yy+0)
_min,_max = math.modf(rx)
if _min>=0.5:
rx = _max+1
else:
rx = _max
_miny,_maxy = math.modf(ry)
if _miny>=0.5:
ry = _maxy+1
else:
ry = _maxy
return rx,ry
def rgb_array(self,table_name):
ddegree = table_name["范围参数"][0]
x1 = table_name["范围参数"][1]
y1 = table_name["范围参数"][2]
x2 = table_name["范围参数"][3]
y2 = table_name["范围参数"][4]
status,ag= self.findMultiColorInRegionFuzzyByTable(table_name["坐标"],ddegree,x1,y1,x2,y2)
if status==status.OK:
return status.OK
else:
return status.NOTMATCH
def tap_(self,D,X,Y):
while True:
##self.queue.put("check")
status,ag= self.findMultiColorInRegionFuzzyByTable(da.zhujiemian)
if status==status.NOTMATCH:
x,y=self.TAPP(D,X,Y)
self.click(x,y)
time.sleep(1)
self.click(da.Table_梦幻[D]["返回"][0],da.Table_梦幻[D]["返回"][1])
time.sleep(2)
break
print("监控坐标")
while True:
pos = self.Ocrtext(da.pos_feature,"CFE3E9,311D17#F8DDCE,072331",100,60,206,85,M=0.26)
if len(pos):
#pos = pos[0]["text"]
if pos[0] == "?":
pos = pos[1:]
if pos[len(pos)-1]=="?":
pos = pos[:len(pos)-1]
postr = pos.replace("\n","")
postr = pos.replace("??","?")
try:
_x = int(postr.split('?')[0])
_y = int(postr.split('?')[1])
time.sleep(1)
print("当前坐标(x:{0},y:{1})----实际坐标(x:{2},y:{3})".format(str(_x),str(_y),str(X),str(Y)))
if (abs(X-_x)<=3) and (abs(Y-_y)<=3):
break
except Exception as e:
print(postr)
def discover_feixingfu(self):
status = State.NOTMATCH
status = self.Found_do(da.utils["飞行符"]["基点"],da.utils["飞行符"]["偏移"], 70,592,170, 1057,538,name="道具栏飞行符")
return status
def no_prop(self):
status,x,y = self.findMultiColorInRegionFuzzy( da.prompt_box["道具栏展开"]["基点"], da.prompt_box["道具栏展开"]["偏移"], 80,1186,648, 1248,706)
if x != -1:
return True
else:
return False
def quit(self):
self.queue.put("exit")
#前往长寿郊外
def go_to_CSJW(self):
#确保道具栏没有被收起来
while True:
#self.queue.put("check")
if self.no_prop():
self.click(1220, 679)
time.sleep(0.5)
if not self.no_prop():
break
else:
break
time.sleep(2)
time.sleep(1)
self.click(1121, 673)
time.sleep(1)
status = self.discover_feixingfu()
if status == status.OK:
print("发现飞行符")
time.sleep(1)
tpl = self.Print_screen()
target = cv2.imread("./images/shiyong.png")
x,y = self.matchTemplate(tpl,target)
if x != -1:
self.click(x,y)
else:
print("飞行符没有使用")
return
time.sleep(1)
self.go_to_CSC()
#打开地图
time.sleep(1)
self.open_map()
time.sleep(1)
self.tap_("长寿村",144,6)
time.sleep(0.5)
while True:
#self.queue.put("check")
status,ag= self.findMultiColorInRegionFuzzyByTable(da.zhujiemian)
if status==status.NOTMATCH:
time.sleep(0.5)
else:
break
while True:
reponse = self.x_Ocrtext(da.scenario,"1C1D21,1B1C20",94, 24,208, 51)
if "长寿郊外" in reponse:
print("抵达长寿郊外")
break
else:
self.mask_(True)
self.click(1038,600)
time.sleep(0.5)
self.mask_(False)
return True
else:
return False
#前往朱紫国
def go_to_ZZG(self):
while True:
status,ag= self.findMultiColorInRegionFuzzyByTable(da.feixingfu_jiemian,degree=80)
if status==status.OK:
time.sleep(0.7)
self.click(573,483)
time.sleep(0.7)
if status==status.NOTMATCH:
break
while True:
status,ag= self.findMultiColorInRegionFuzzyByTable(da.zhujiemian,degree=80)
time.sleep(0.5)
if status==status.NOTMATCH:
print("前往朱紫国")
status,ag= self.findMultiColorInRegionFuzzyByTable(da.fanhui)
if status==status.OK:
self.click(ag[0],ag[1])
time.sleep(2)
elif status==status.OK:
while True:
reponse = self.x_Ocrtext(da.scenario,"1C1D21,1B1C20",94,24,208,51,similarity=0.3)
if "朱紫国" in reponse:
print("抵达朱紫国")
break
break
return True
#去往大唐境外
def TotheDTJW(self):
while True:
if self.no_prop():
self.click(1220, 679)
time.sleep(0.5)
if not self.no_prop():
break
else:
break
time.sleep(2)
self.click(1121, 673)
time.sleep(1)
status = self.discover_feixingfu()
if status == status.OK:
print("发现飞行符")
time.sleep(1)
tpl = self.Print_screen()
target = cv2.imread("./images/shiyong.png")
x,y = self.matchTemplate(tpl,target)
if x != -1:
self.click(x,y)
else:
print("飞行符没有使用")
return
#self.click(654,669)
time.sleep(1)
self.go_to_ZZG()
#打开地图
time.sleep(1)
self.open_map()
time.sleep(1)
#if self.rgb_array(da.map_feature["朱紫国"])==State.OK:
self.tap_("朱紫国",6,4)
time.sleep(0.5)
while True:
#self.queue.put("check")
status,ag= self.findMultiColorInRegionFuzzyByTable(da.zhujiemian)
if status==status.NOTMATCH:
time.sleep(0.5)
else:
self.click(42,656)
time.sleep(0.5)
break
while True:
reponse = self.x_Ocrtext(da.scenario,"1C1D21,1B1C20",94, 24,208, 51)
if "大唐境外" in reponse:
print("抵达大唐境外")
break
else:
time.sleep(0.5)
#前往墨家村
def TotheMJC(self):
self.TotheDTJW()
self.open_map()
time.sleep(1)
self.tap_("大唐境外",233,109)
self.mask_(True)
time.sleep(0.5)
while True:
status,ag= self.findMultiColorInRegionFuzzyByTable(da.map_feature["火焰山土地"]["坐标"])
if status == status.NOTMATCH:
time.sleep(0.5)
else:
self.click(785,174)
time.sleep(0.5)
break
while True:
status,ag= self.findMultiColorInRegionFuzzyByTable(da.map_feature["送我进墨家村"]["坐标"],degree=80)
if status == status.NOTMATCH:
time.sleep(0.5)
else:
self.click(1045,246)
time.sleep(0.5)
break
time.sleep(0.5)
self.mask_(False)
while True:
reponse = self.x_Ocrtext(da.scenario,"1C1D21,1B1C20",94, 24,208, 51)
if "墨家村" in reponse:
print("抵达目的地")
return
#前往大唐国境
def ToDTGJ(self):
while True:
if self.no_prop():
self.click(1220, 679)
time.sleep(0.5)
if not self.no_prop():
break
else:
break
time.sleep(2)
self.click(1121, 673)
time.sleep(0.2)
self.flag_transfer("red")
time.sleep(0.5)
q = False
while True:
status,ag= self.findMultiColorInRegionFuzzyByTable(da.flag_jiemian)
if status==status.NOTMATCH:
if q:
self.click(1070,54)
time.sleep(0.5)
status,ag= self.findMultiColorInRegionFuzzyByTable(da.zhujiemian,degree=80)
if status==status.NOTMATCH:
time.sleep(0.5)
else:
break
else:
q = True
self.click(185,602)
time.sleep(0.2)
while True:
reponse = self.x_Ocrtext(da.scenario,"1C1D21,1B1C20",94, 24,208, 51)
if "大唐国境" in reponse:
print("抵达目的地")
return
else:
time.sleep(0.5)
self.click(12,704)
time.sleep(0.5)
#前往麒麟山
def TotheQLS(self):
while True:
if self.no_prop():
self.click(1220, 679)
time.sleep(0.5)
if not self.no_prop():
break
else:
break
time.sleep(2)
self.click(1121, 673)
time.sleep(1)
status = self.discover_feixingfu()
if status == status.OK:
print("发现飞行符")
time.sleep(1)
tpl = self.Print_screen()
target = cv2.imread("./images/shiyong.png")
x,y = self.matchTemplate(tpl,target)
if x != -1:
self.click(x,y)
else:
print("飞行符没有使用")
return
time.sleep(1)
self.go_to_ZZG()
#打开地图
time.sleep(1)
self.open_map()
time.sleep(1)
self.tap_("朱紫国",3,111)
time.sleep(0.5)
while True:
status,ag= self.findMultiColorInRegionFuzzyByTable(da.zhujiemian)
if status==status.NOTMATCH:
time.sleep(0.5)
else:
break
while True:
reponse = self.x_Ocrtext(da.scenario,"1C1D21,1B1C20",94, 24,208, 51)
if "麒麟山" in reponse:
print("抵达目的地")
return
else:
self.mask_(True)
self.click(14,98)
time.sleep(0.5)
self.mask_(False)
#前往狮驼岭
def TotheSTL(self):
self.TotheDTJW()
self.open_map()
time.sleep(1)
self.tap_("大唐境外",7,49)
while True:
status,ag= self.findMultiColorInRegionFuzzyByTable(da.zhujiemian)
if status==status.NOTMATCH:
time.sleep(0.5)
else:
break
while True:
reponse = self.x_Ocrtext(da.scenario,"1C1D21,1B1C20",94, 24,208, 51)
if "狮驼岭" in reponse:
print("抵达目的地")
return
else:
self.click(18,348)
time.sleep(0.5)
#前往东海湾
def ToTheDHW(self):
while True:
#self.queue.put("check")
if self.no_prop():
self.click(1220, 679)
time.sleep(0.5)
if not self.no_prop():
break
else:
break
time.sleep(2)
self.click(1121, 673)
time.sleep(0.2)
self.flag_transfer("yellow")
time.sleep(0.5)
q = False
while True:
status,ag= self.findMultiColorInRegionFuzzyByTable(da.flag_jiemian)
if status==status.NOTMATCH:
if q:
self.click(1070,54)
time.sleep(0.5)
status,ag= self.findMultiColorInRegionFuzzyByTable(da.zhujiemian)
if status==status.NOTMATCH:
time.sleep(0.5)
else:
break
else:
q = True
self.click(815,558)
time.sleep(0.2)
self.mask_(True)
while True:
# status,ag= self.findMultiColorInRegionFuzzyByTable(da.map_feature["驿站老板"]["坐标"])
# if status == status.NOTMATCH:
# time.sleep(0.5)
# else:
self.click(640,405)
time.sleep(0.5)
break
while True:
status,ag= self.findMultiColorInRegionFuzzyByTable(da.map_feature["我要去"]["坐标"])
if status == status.NOTMATCH:
time.sleep(0.5)
else:
self.click(1062,340)
time.sleep(0.5)
break
self.mask_(False)
while True:
reponse = self.x_Ocrtext(da.scenario,"1C1D21,1B1C20",94, 24,208, 51)
if "东海湾" in reponse:
print("抵达目的地")
return
#前往江南野外
def ToTheJNYW(self):
while True:
if self.no_prop():
self.click(1220, 679)
time.sleep(0.5)
if not self.no_prop():
break
else:
break
time.sleep(2)
self.click(1121, 673)
time.sleep(0.2)
self.flag_transfer("red")
time.sleep(0.5)
q = False
while True:
status,ag= self.findMultiColorInRegionFuzzyByTable(da.flag_jiemian)
if status==status.NOTMATCH:
if q:
self.click(1070,54)
time.sleep(0.5)
status,ag= self.findMultiColorInRegionFuzzyByTable(da.zhujiemian)
if status==status.NOTMATCH:
time.sleep(0.5)
else:
break
else:
q = True
self.click(1069,604)
time.sleep(0.2)
while True:
reponse = self.x_Ocrtext(da.scenario,"1C1D21,1B1C20",94, 24,208, 51)
if "江南野外" in reponse:
print("抵达目的地")
break
else:
self.mask_(True)
self.click(1190,697)
time.sleep(0.5)
self.mask_(False)
while True:
if self.no_prop():
self.click(1220, 679)
time.sleep(0.5)
if not self.no_prop():
break
else:
break
#前往花果山
def ToTheHGS(self):
while True:
if self.no_prop():
self.click(1220, 679)
time.sleep(0.5)
if not self.no_prop():
break
else:
break
time.sleep(2)
self.click(1121, 673)
time.sleep(0.2)
self.flag_transfer("yellow")
time.sleep(0.5)
q = False
while True:
status,ag= self.findMultiColorInRegionFuzzyByTable(da.flag_jiemian)
if status==status.NOTMATCH:
if q:
self.click(1070,54)
time.sleep(0.5)
status,ag= self.findMultiColorInRegionFuzzyByTable(da.zhujiemian)
if status==status.NOTMATCH:
time.sleep(0.5)
else:
break
else:
q = True
#
self.click(962,163)
time.sleep(0.2)
while True:
reponse = self.x_Ocrtext(da.scenario,"1C1D21,1B1C20",94, 24,208, 51)
if "花果山" in reponse:
print("抵达目的地")
return
else:
self.mask_(True)
time.sleep(1)
self.click(1241,80)
time.sleep(1)
self.mask_(False)
#前往傲来国
def ToTheALG(self):
while True:
#self.queue.put("check")
if self.no_prop():
self.click(1220, 679)
time.sleep(0.5)
if not self.no_prop():
break
else:
break
time.sleep(2)
self.click(1121, 673)
time.sleep(1)
status = self.discover_feixingfu()
if status == status.OK:
print("发现飞行符")
time.sleep(1)
tpl = self.Print_screen()
target = cv2.imread("./images/shiyong.png")
x,y = self.matchTemplate(tpl,target)
if x != -1:
self.click(x,y)
else:
print("飞行符没有使用")
return
time.sleep(1)
while True:
status,ag= self.findMultiColorInRegionFuzzyByTable(da.feixingfu_jiemian)
if status==status.OK:
time.sleep(0.7)
self.click(1010,521)
time.sleep(0.7)
break
while True:
status,ag= self.findMultiColorInRegionFuzzyByTable(da.zhujiemian)
time.sleep(0.5)
if status==status.NOTMATCH:
print("前往傲来国")
status,ag= self.findMultiColorInRegionFuzzyByTable(da.fanhui)
if status==status.OK:
self.click(ag[0],ag[1])
time.sleep(1)
elif status==status.OK:
while True:
reponse = self.x_Ocrtext(da.scenario,"1C1D21,1B1C20",94, 24,208, 51)
if "傲来国" in reponse:
print("抵达傲来国")
break
break
return True
#前往五庄观
def ToTheWZG(self):
self.ToDTGJ()
#打开地图
time.sleep(1)
self.open_map()
time.sleep(1)
self.tap_("大唐国境",5,79)
time.sleep(0.5)
self.mask_(True)
self.click(16,195)
time.sleep(0.5)
self.mask_(False)
while True:
reponse = self.x_Ocrtext(da.scenario,"1C1D21,1B1C20",94, 24,208, 51)
if "大唐境外" in reponse:
print("抵达大唐境外")
break
else:
time.sleep(1)
time.sleep(1)
self.open_map()
time.sleep(1)
self.tap_("大唐境外",633,76)
while True:
reponse = self.x_Ocrtext(da.scenario,"1C1D21,1B1C20",94, 24,208, 51)
if "五庄观" in reponse:
print("抵达五庄观")
break
else:
self.mask_(True)
self.click(1245,200)
time.sleep(0.2)
self.mask_(False)
def open_prop(self):
while True:
if self.no_prop():
self.click(1220, 679)
time.sleep(0.5)
if not self.no_prop():
break
else:
break
time.sleep(2)
time.sleep(0.5)
self.click(1121, 673)
while True:
status,x,y=self.findMultiColorInRegionFuzzy(da.prompt_box["打开地图界面"]["基点"],da.prompt_box["打开地图界面"]["偏移"], 88, 622,3, 1207, 307)
if status == State.NOTMATCH:
print("当前没有打开道具栏")
time.sleep(0.5)
self.click(1121, 673)
else:
print("已经打开道具栏")
break
#前往普陀山
def ToThePTS(self):
self.ToDTGJ()
time.sleep(1)
self.open_map()
time.sleep(1)
self.tap_("大唐国境",228,58)
time.sleep(0.5)
self.mask_(True)
while True:
status,ag= self.findMultiColorInRegionFuzzyByTable(da.map_feature["传送仙女"]["坐标"])
if status == status.NOTMATCH:
time.sleep(0.5)
else:
self.click(508, 254)
time.sleep(0.5)
break
while True:
status,ag= self.findMultiColorInRegionFuzzyByTable(da.map_feature["我要去"]["坐标"])
if status == status.NOTMATCH:
time.sleep(0.5)
else:
self.click(1062,340)
time.sleep(0.5)
break
self.mask_(False)
while True:
reponse = self.x_Ocrtext(da.scenario,"1C1D21,1B1C20",94, 24,208, 51)
if "普陀山" in reponse:
print("抵达普陀山")
break
def config_load(self):
load_dict = None
time.sleep(1)
with open("./player.json", 'r',encoding="utf-8") as f:
load_dict = json.load(f)
return load_dict
def config_save(self,maps):
load_dict = dict()
#maps.remove(m)
load_dict["tu"]=maps
with open("./player.json", 'w',encoding="utf-8") as f:
json.dump(load_dict,f,ensure_ascii=False,indent = 4)
def orb_(self,place,place_x,place_y,x1,y1,x2,y2):
bF = True
time.sleep(1)
self.open_map()
time.sleep(1)
self.tap_(place,place_x,place_y)
self.open_prop()
time.sleep(1)
#判断提示框是否出现
while True:
status,x,y = self.findMultiColorInRegionFuzzy( da.daoju["普通宝图A"]["基点"], da.daoju["普通宝图A"]["偏移"], 45,x1-5,y1-5,x2,y2)
if status==status.OK:
self.click(x1+5,y1+5)
self.click(x1+5,y1+5)
self.click(x1+5,y1+5)
self.click(x1+5,y1+5)
bF=False