def receive_done_sub(get_img=get_img): """收远征完成""" sleep(1) for num in range(0, 3): # 找完成的远征 point = mathc_img(get_img(), "DONE", 0.9) point = remove_same(point) # 找到可以收的远征 if point: game_log.info("RECEIVE") click(point[0]) point = [] sleep(1) # 找MARCHDONE start = time() while 1: if time() - start > 60: raise OvertimeError("receive1") point = mathc_img(get_img(), "MARCHDONE", 0.9) if point: point = [] break sleep(STEP * 2) # 在回到远征界面前一直点 start = time() while 1: if time() - start > 60: raise OvertimeError("receive2") if marchfind(): break click(792, 818) sleep(2) # 没远征可收 else: return
def extra(s): """残血操作""" # print('extra:%d' % s) if isinstance(s, int): if s == 1: """全集中""" attack(2) attack(2) attack(2) elif s == 2: """全分散""" attack(1) attack(1) attack(1) elif s == 3: """一半集中一半分散""" attack(1) attack(2) attack(1) elif s == 4: """有什么符卡放什么""" graze(1) boost(1) card(4) card(3) card(2) card(1) click(79, 593) attack(2) return s else: return s()
def MAIN_way(target): "从 主页 出发" if target == "FIGHT": click(1478, 712) return "FIGHT" elif target == "MARCH": click(1380, 534) return "MARCH"
def offlinefind(img=get_img): """断网判定""" if search("OFFLINE"): click(963, 632) # 断网重连操作 game_log.warning("offline") sleep(10) return True else: return False
def receive_done_main(): """收远征""" sleep(5) receive_done_sub() down_swipe() receive_done_sub() click(73, 329) receive_done_sub() down_swipe() receive_done_sub()
def offlinefind(flag=0): """断网判定""" if search("OFFLINE"): game_log.warning("offline") click(963, 632) # 断网重连操作 sleep(10) offlinefind() # if flag == 1: # end("next") return True else: return False
def go_to_march(): """进入远征界面""" click(1387, 543) sleep(3) start = time() while 1: if time() - start > 60: raise OvertimeError("go") marchfind() offlinefind() if marchfind(): break sleep(STEP * 2)
def adjust(sel): """调整难度 :sel: 1:normal 2:hard 3:lunatic """ while True: if search("LUNATIC"): now = 3 elif search("HARD"): now = 2 elif search("NORMAL"): now = 1 if now == sel: break else: click(541, 808)
def selection(stage): if isinstance(stage, int): # print("select {0}".format(stage)) if stage == 1: click(1105, 231) # 选关1 elif stage == 2: click(1105, 426) # 选关2 elif stage == 3: click(1105, 612) # 选关3 elif stage == 4: click(1105, 700) else: point = mathc_img(get_img(), stage, 0.9) if point: click(point[0]) else: self.before_fight() self.select_stage(self, number)
def select_player(): # 选人 start = time() while 1: if time() - start > 60: raise OvertimeError("select_player1") sleep(2) point = mathc_img(get_img(), "ADDGIRL", 0.8) point = remove_same(point) if point: click(point[0]) break # 确定 start = time() while 1: if time() - start > 60: raise OvertimeError("select_player2") point = mathc_img(get_img(), "YES", 0.8) point = remove_same(point) if point: click(point[0]) break sleep(2) click(75, 186) up_swipe()
def end(sel): """结束处理""" click(500, 500) start = time() while 1: if time() - start > 60: raise OvertimeError("end") offlinefind() if againfind() or nextfind(): break sleep(STEP * 3) if waterfind(): print("water find") click(1415, 813) raise Watererror("end") elif sel == "next": click(1415, 813) elif sel == "again": click(181, 814)
def go(team): """队伍选择""" # 判断当前队伍 计算距目标的距离 start = time() while 1: if time() - start > 60: raise OvertimeError("go") value = search("TEAMFIND") value = value + 1 - team if value == 0: power_use = powerfind() # print(power_use) click(1338, 796) return power_use elif value > 0: click(58, 534) else: click(1030, 534) sleep(2)
def start(self): """远征全家桶""" if not (self.skill_room or self.receive_march or self.send_march): return try: # 道场续书 exit_to_main() if self.skill_room: skill_room() sleep(3) if not mainpage_marchfind(): mode = (self.receive_march, self.send_march) # 在"收+发"和"收"模式时,如果没有远征可以收就退出远征模式 if mode == (1, 1) or mode == (1, 0): game_log.info("no march is done") click(1472, 717) return go_to_march() # 收远征 if self.receive_march: self.receive() # 发远征 if not self.send_march: exit_to_main() click(1472, 717) sleep(3) return # 初始化 march_list = March.initialize() # 远征优先级 modelist = ["gold2", "gold1", "power", "card", "book", "nothing"] # 做远征 self.send(march_list, modelist) game_log.info("march done") exit_to_main() click(1472, 717) sleep(3) except OvertimeError as err: game_log.error(err.type) self.start()
except OvertimeError as err: game_log.error(err.type) self.start() if __name__ == "__main__": Sub.start() while 1: # 道场技能150 point = mathc_img(get_img(), "EXP", 0.8) point = remove_same(point) if point: for p in point: if p[0] > 800: point.remove(p) print(point) x = int(point[1][0]) y = int(point[1][1] + 30) click(x, y, 2) # 银书 click(1322, 764, 1) click(992, 632, 1) sleep(3) continue # 道场确定 point = mathc_img(get_img(), "SKILLPOINT", 0.9) if point: point = remove_same(point) click(point[0]) sleep(3) continue
def skill_room(): """道场续书""" # 设施有红点吗 if not mainpage_buildingfind(): return click(800, 800, 3) # 道场有红点吗 if not mainpage_building_skill_room_point(): click(792, 772) return click(1316, 464) start = time() num = 0 while 1: sleep(5) if time() - start > 60: break raise OvertimeError("skill_room") # 道场技能150 point = mathc_img(get_img(), "EXP", 0.8) point = remove_same(point) if point: for p in point: if p[0] > 800: point.remove(p) # print(point) click(int(point[1][0]), int(point[1][1] + 50), 1) # 银书 click(1322, 764, 1) click(992, 632, 1) num += 1 continue # 道场确定 point = mathc_img(get_img(), "SKILLPOINT", 0.9) if point: point = remove_same(point) click(point[0]) continue if num == 3: break exit_to_main()
def restart_game(self): "游戏重启" start = time() while 1: if time() - start > 120: restart_program() if startfind(): break elif offlinefind(): pass elif boostfind(): click(858, 34) # 强行中断战斗 sleep(2) click(1408, 808) click(992, 628) elif endfind(): end("next") elif gofind(): click(48, 48) elif againfind(): click(1412, 812) click(500, 500) sleep(5)
def send_done(march): """做远征""" num = march.number + 1 # print(num) click(75, 186) up_swipe() # 普通远征 if num == 1: click(576, 207) return elif num == 2: click(560, 440) return elif num == 3: click(599, 666) return else: down_swipe() if num == 4: click(846, 520) return elif num == 5: click(866, 762) return # 限时远征 前三个 else: click(72, 336) if num == 6: click(576, 207) return elif num == 7: click(560, 440) return elif num == 8: click(599, 666) return else: down_swipe() # 限时远征 后三个 if num == 9: click(570, 306) return elif num == 10: click(600, 540) return elif num == 11: click(756, 770) return
def initialize(cls, get_img=get_img): """初始化 需要处在远征界面 """ def cut(img): """切出每个远征的小图""" # 找到所以基准点 point = mathc_img(img, "LV", 0.7) point = remove_same(point) # 图片切片 piclist = [] for num in range(0, len(point)): y0 = point[num][1] - 34 y1 = point[num][1] + 186 x0 = point[num][0] - 296 x1 = point[num][0] + 907 piclist.append(cut_image(y0, y1, x0, x1, img)) return piclist # 普通远征 click(73, 179) up_swipe() sleep(1) piclist = cut(get_img()) piclist.pop() down_swipe() sleep(1) pic2list = cut(get_img()) pic2list.pop(0) piclist = piclist + pic2list sleep(1) march_list = [] for number in range(0, 5): march_list.append(cls(piclist[number], number)) # 特殊远征 click(73, 329) sleep(1) up_swipe() sleep(1) piclist = cut(get_img()) if piclist: # 限时远征少于3个,一次搞定 if len(piclist) <= 3: for number in range(0, len(piclist)): march_list.append(cls(piclist[number], number + 5)) # 限时远征多于3个 else: # 限时远征个数判断 n = number_find() piclist.pop() down_swipe() sleep(1) pic2list = cut(get_img()) if n == 5: pic2list.pop(0) if n == 4: pic2list.pop(0) pic2list.pop(0) piclist = piclist + pic2list for number in range(0, len(piclist)): march_list.append(cls(piclist[number], number + 5)) return march_list[0:9]
def BOOST_way(target): "从 战斗 出发" click(858, 34, 3) # 强行中断战斗 click(1408, 808) click(992, 628) return "FIGHT"
def END_way(target): "从 结束 出发" click(500, 500) return "NEXT"
def NEXT_way(target): "从 结束1 出发" click(1415, 813) return "FIGHT"