def connect(self, broadcast = True): self.connectSwitch = True for times in range(10): if self.connectSwitch: if self.adb.connect(): return True else: return False else: if broadcast: toast.broadcastMsg("ArkHelper", "连接模拟器失败,请检查设置和模拟器", self.ico) print('unable to connect simulator') else: print("INIT:adb connect failed") return False
def run(self, switchI): self.switch = switchI isNormal = True flag = self.goToMainpage() if self.switch and flag: infoFlag = self.openCard() if self.switch and infoFlag != None: infoFlag2 = self.openFriendList(infoFlag) if self.switch and infoFlag2 != None: self.enterCons(infoFlag2) else: isNormal = False else: isNormal = False else: isNormal = False self.goToMainpage() if isNormal and self.switch: toast.broadcastMsg("ArkHelper", "获取信用点成功", self.icon) elif self.switch: toast.broadcastMsg("ArkHelper", "获取信用点出错", self.icon) self.switch = False
def run(self, switchI): self.switch = switchI condition0 = self.goToMainpage() if condition0: condition1 = self.checkTask() if condition1: self.oneByOne() if self.switch and (not condition0): toast.broadcastMsg("ArkHelper", "任务交付出错", self.icon) elif self.switch and (not condition1): toast.broadcastMsg("ArkHelper", "无需任务交付", self.icon) elif self.switch: self.goToMainpage() toast.broadcastMsg("ArkHelper", "任务交付完成", self.icon) self.switch = False
def run(self, switchI): isInBattle = False restStone = self.stoneMaxNum #isFirstTurn = True self.switch = switchI self.isUselessContinue = False if self.switch: while self.switch: self.adb.screenShot() #判断代理指挥是否勾选 '''if isFirstTurn: isFirstTurn = False''' picStartA = pictureFind.matchImg(self.screenShot, self.startA, confidencevalue= 0.9) if picStartA != None and self.switch: picIsUseless = pictureFind.matchImg(self.screenShot, self.uselessLevel) if picIsUseless and (not self.isUselessContinue): self.isWaitingUser = True self.signal.emit() while self.isWaitingUser: sleep(1) continue else: picAutoOn = pictureFind.matchImg(self.screenShot, self.autoOn) if picAutoOn == None and self.switch: picAutoOff = pictureFind.matchImg(self.screenShot, self.autoOff) if picAutoOff != None and self.switch: posAutoOff = picAutoOff['result'] self.adb.click(posAutoOff[0], posAutoOff[1]) continue '''isDelayExit = False #加载延迟是否出现,即检查到开始行动A但实际上是正在进入关卡前的状态 for i in range(5): if not self.switch: break isSSSuccess = self.adb.screenShot() if not isSSSuccess: print('unable to get screenshot') self.switchB = False return False for eachObj in self.listBattleImg: picInfo = pictureFind.matchImg(self.screenShot, eachObj, 0.8) if picInfo != None: if eachObj['obj'] != "startApart.png": isDelayExit = True break picAutoOn = pictureFind.matchImg(self.screenShot, self.autoOn) if picAutoOn != None or isDelayExit: if isDelayExit: print("start delay exit") break''' #sleep(1) for eachObj in self.listImg: if self.switch: if eachObj['obj'] == "end.png" or eachObj['obj'] == "levelup.png": confidence = 0.8 else: confidence = 0.9 #print(self.screenShot + ' ' + self.cwd + '/res/battle/' + eachObj) picInfo = pictureFind.matchImg(self.screenShot, eachObj, confidence) #print(eachObj+ ':', picInfo) if picInfo != None: if picInfo['result'][1] < 270: continue if eachObj['obj'] == "startBpart.png": isInBattle = True else: isInBattle = False picPos = picInfo['result'] if eachObj['obj'] == "cancel.png": if self.autoRecMed or self.autoRecStone: medInfo = pictureFind.matchImg(self.screenShot, self.recMed) stoneInfo = pictureFind.matchImg(self.screenShot, self.recStone) confirmInfo = pictureFind.matchImg(self.screenShot, self.confirm) if (not self.autoRecMed) and (self.autoRecStone): if medInfo != None and stoneInfo == None: self.adb.click(medInfo['result'][0]+350, medInfo['result'][1], isSleep= True) self.adb.screenShot() medInfo = pictureFind.matchImg(self.screenShot, self.recMed) stoneInfo = pictureFind.matchImg(self.screenShot, self.recStone) if medInfo == None and stoneInfo != None: if restStone >0: self.adb.click(confirmInfo['result'][0], confirmInfo['result'][1], isSleep= True) restStone -= 1 break elif medInfo == None and stoneInfo != None: if restStone >0: self.adb.click(confirmInfo['result'][0], confirmInfo['result'][1], isSleep= True) restStone -= 1 break self.adb.click(picPos[0], picPos[1], isSleep = True) self.switch = False toast.broadcastMsg("ArkHelper", "理智耗尽", self.ico) else: if self.autoRecMed: if medInfo != None: self.adb.click(confirmInfo['result'][0], confirmInfo['result'][1], isSleep= True) break if self.autoRecStone: if stoneInfo != None: if restStone >0: self.adb.click(confirmInfo['result'][0], confirmInfo['result'][1], isSleep= True) restStone -= 1 break self.adb.click(picPos[0], picPos[1], isSleep = True) self.switch = False toast.broadcastMsg("ArkHelper", "理智耗尽", self.ico) else: self.adb.click(picPos[0], picPos[1], isSleep = True) self.switch = False toast.broadcastMsg("ArkHelper", "理智耗尽", self.ico) elif eachObj['obj'] == 'stoneLack.png': self.adb.click(picPos[0], picPos[1], isSleep = True) self.switch = False toast.broadcastMsg("ArkHelper", "理智耗尽", self.ico) elif eachObj['obj'] == 'levelup.png': lackTem = False for eachTem in self.listImg: if eachTem['obj'] == 'stoneLack.png': lackTem = eachTem break if lackTem: picLackInfo = pictureFind.matchImg(self.screenShot, lackTem, 0.9) if picLackInfo: self.adb.click(picLackInfo['result'][0], picLackInfo['result'][1], isSleep = True) self.switch = False toast.broadcastMsg("ArkHelper", "理智耗尽", self.ico) else: self.adb.click(picPos[0], picPos[1], isSleep = True) if eachObj['obj'] == 'startApartOF.png': self.adb.screenShot() OFend = pictureFind.matchImg(self.screenShot, self.cwd + '/res/act/OFend.png', 0.8) if OFend != None: self.switch = False toast.broadcastMsg("ArkHelper", "黑曜石节门票不足", self.ico) else: self.adb.click(picPos[0], picPos[1], isSleep = True) if eachObj['obj'] == 'startApartOF.png': self.adb.screenShot() OFend = pictureFind.matchImg(self.screenShot, self.cwd + '/res/act/OFend.png', 0.8) if OFend != None: self.switch = False toast.broadcastMsg("ArkHelper", "黑曜石节门票不足", self.ico) else: self.adb.click(picPos[0], picPos[1], isSleep = True) if eachObj['obj'] == 'startApartOF.png': self.adb.screenShot() OFend = pictureFind.matchImg(self.screenShot, self.cwd + '/res/act/OFend.png', 0.8) if OFend != None: self.switch = False toast.broadcastMsg("ArkHelper", "黑曜石节门票不足", self.ico) break if isInBattle: sleep(1)
def runTimes(self, times=1): bootyName = None if isinstance(times, dict): bootyMode = True bootyName = times['bootyName'] times = int(times['bootyNum']) else: bootyMode = False times = int(times) #isFirstTurn = True countStep = 0 totalCount = 0 bootyTotalCount = 0 twiceTry = 0 while self.switch and self.switchB: self.adb.screenShot() #判断代理指挥是否勾选 '''if isFirstTurn: isFirstTurn = False''' picStartA = pictureFind.matchImg(self.screenShot, self.startA, confidencevalue=0.9) if picStartA != None and self.switch and self.switchB: picAutoOn = pictureFind.matchImg(self.screenShot, self.autoOn) if picAutoOn == None and self.switch and self.switchB: picAutoOff = pictureFind.matchImg(self.screenShot, self.autoOff) if picAutoOff != None and self.switch and self.switchB: posAutoOff = picAutoOff['result'] self.adb.click(posAutoOff[0], posAutoOff[1]) continue '''isDelayExit = False #加载延迟是否出现,即检查到开始行动A但实际上是正在进入关卡前的状态 #这段代码我不是很清楚我当时为什么会写,现在看来毫无用处,但先留在注释里 for i in range(5): if not (self.switch and self.switchB): break isSSSuccess = self.adb.screenShot() if not isSSSuccess: print('unable to get screenshot') self.switchB = False return False for eachObj in self.listBattleImg: if not (self.switch and self.switchB): break picInfo = pictureFind.matchImg(self.screenShot, eachObj, 0.8) if picInfo != None: if eachObj['obj'] != "startApart.png": isDelayExit = True break picAutoOn = pictureFind.matchImg(self.screenShot, self.autoOn) if picAutoOn != None or isDelayExit: if isDelayExit: print("start delay exit") break else: print('auto mode still off') self.switchB = False return True #返回True用来跳过此关''' isInBattle = False #sleep(1) for eachObj in self.listBattleImg: if self.switch and self.switchB: if eachObj['obj'] == "end.png" or eachObj[ 'obj'] == "levelup.png": confidence = 0.8 else: confidence = 0.9 #print(self.screenShot + ' ' + self.cwd + '/res/battle/' + eachObj) picInfo = pictureFind.matchImg(self.screenShot, eachObj, confidence) #print(eachObj+ ':', picInfo) if picInfo != None: if picInfo['result'][1] < 270: continue if eachObj['obj'] == "startBpart.png": isInBattle = True else: isInBattle = False picPos = picInfo['result'] if countStep == 0: if eachObj['obj'] == 'startBpart.png': countStep += 1 elif countStep == 1: if eachObj['obj'] == 'endNormal.png': countStep += 1 if bootyMode: for i in range(10): temp = imread(self.screenShot) self.adb.screenShot() if pictureFind.matchImg( temp, self.screenShot, confidencevalue=0.99) != None: break sleep(1) bootyTotalCount += self.BootyDetect.bootyCheck( bootyName, self.screenShot) print( f'{bootyName} 应获得:{times} 实获得:{bootyTotalCount}' ) elif countStep == 2: if eachObj['obj'] == 'startApart.png': countStep += 1 if countStep == 3: countStep = 0 totalCount += 1 if (totalCount == times) and (not bootyMode): self.switchB = False return True if (bootyTotalCount >= times) and bootyMode: self.adb.click(picPos[0], picPos[1], isSleep=True) self.switchB = False return True '''self.adb.click(picPos[0], picPos[1], isSleep = True) if eachObj['obj'] == "cancel.png": self.switch = False self.switchB = False toast.broadcastMsg("ArkHelper", "理智耗尽", self.ico) return False break''' if eachObj['obj'] == "cancel.png": if self.autoRecMed or self.autoRecStone: medInfo = pictureFind.matchImg( self.screenShot, self.recMed) stoneInfo = pictureFind.matchImg( self.screenShot, self.recStone) confirmInfo = pictureFind.matchImg( self.screenShot, self.confirm) if (not self.autoRecMed) and ( self.autoRecStone): if medInfo != None and stoneInfo == None: self.adb.click(medInfo['result'][0] + 350, medInfo['result'][1], isSleep=True) self.adb.screenShot() medInfo = pictureFind.matchImg( self.screenShot, self.recMed) stoneInfo = pictureFind.matchImg( self.screenShot, self.recStone) if medInfo == None and stoneInfo != None: if self.restStone > 0: self.adb.click( confirmInfo['result'][0], confirmInfo['result'][1], isSleep=True) self.restStone -= 1 break elif medInfo == None and stoneInfo != None: if self.restStone > 0: self.adb.click( confirmInfo['result'][0], confirmInfo['result'][1], isSleep=True) self.restStone -= 1 break self.adb.click(picPos[0], picPos[1], isSleep=True) self.switch = False self.switchB = False toast.broadcastMsg("ArkHelper", "理智耗尽", self.ico) return False else: if self.autoRecMed: if medInfo != None: self.adb.click( confirmInfo['result'][0], confirmInfo['result'][1], isSleep=True) break if self.autoRecStone: if stoneInfo != None: if self.restStone > 0: self.adb.click( confirmInfo['result'][0], confirmInfo['result'][1], isSleep=True) self.restStone -= 1 break self.adb.click(picPos[0], picPos[1], isSleep=True) self.switch = False self.switchB = False toast.broadcastMsg("ArkHelper", "理智耗尽", self.ico) return False else: self.adb.click(picPos[0], picPos[1], isSleep=True) self.switch = False self.switchB = False toast.broadcastMsg("ArkHelper", "理智耗尽", self.ico) return False elif eachObj['obj'] == "stoneLack.png": self.adb.click(picPos[0], picPos[1], isSleep=True) self.switch = False self.switchB = False toast.broadcastMsg("ArkHelper", "理智耗尽", self.ico) return False elif eachObj['obj'] == 'levelup.png': lackTem = False for eachTem in self.listBattleImg: if eachTem['obj'] == 'stoneLack.png': lackTem = eachTem break if lackTem: picLackInfo = pictureFind.matchImg( self.screenShot, lackTem, 0.9) if picLackInfo: self.adb.click(picLackInfo['result'][0], picLackInfo['result'][1], isSleep=True) self.switch = False toast.broadcastMsg("ArkHelper", "理智耗尽", self.ico) else: self.adb.click(picPos[0], picPos[1], isSleep=True) if eachObj['obj'] == 'startApartOF.png': self.adb.screenShot() OFend = pictureFind.matchImg( self.screenShot, self.cwd + '/res/act/OFend.png', 0.8) if OFend != None: self.switch = False toast.broadcastMsg( "ArkHelper", "黑曜石节门票不足", self.ico) else: self.adb.click(picPos[0], picPos[1], isSleep=True) if eachObj['obj'] == 'startApartOF.png': self.adb.screenShot() OFend = pictureFind.matchImg( self.screenShot, self.cwd + '/res/act/OFend.png', 0.8) if OFend != None: self.switch = False toast.broadcastMsg( "ArkHelper", "黑曜石节门票不足", self.ico) else: self.adb.click(picPos[0], picPos[1], isSleep=True) break else: break if isInBattle: sleep(1)