Пример #1
0
def compareWithFile(x, y, filename, corr=HIGH_CORR, log=None):
    corrword = 'HIGH' if corr == HIGH_CORR else 'LOW'
    root.debug("Compare image with asset, {} CORRERLATION".format(corrword))
    t = tm.Trainer(img, x, y)
    location = defaultlocations.assets
    location = os.path.join(location, filename)
    if t.getMatches(location, corr):
        x, y = t.kmeans.cluster_centers_[0]
        if log:
            log.writeLog()
        utils.Tap(x, y)
Пример #2
0
def compareWithBackButton(corr=HIGH_CORR, log=None):
    corrword = 'HIGH' if corr == HIGH_CORR else 'LOW'
    root.debug("LOOKING FOR BACK BUTTON, {} CORRERLATION".format(corrword))
    img = utils.GetImgFromScreenShot()
    t = tm.Trainer(img, 150, 720)
    location = defaultlocations.assets
    location = os.path.join(location, "back__.png")
    if t.getMatches(location, corr):
        x, y = t.kmeans.cluster_centers_[0]
        if log:
            log.writeLog()
        utils.Tap(x, y)
        return True
    return False
Пример #3
0
def ScanForClose(corr=HIGH_CORR, log=None):
    corrword = 'HIGH' if corr == HIGH_CORR else 'LOW'
    root.debug("LOOKING FOR CLOSE BUTTON, {} CORRERLATION".format(corrword))
    img = utils.GetImgFromScreenShot()
    t = tm.Trainer(img, 480, 500)
    location = defaultlocations.assets
    location = os.path.join(location, "close.png")
    if t.getMatches(location, corr):
        x, y = t.kmeans.cluster_centers_[0]
        if log:
            log.writeLog()
        utils.Tap(x, y)
        return True
    return False
Пример #4
0
 def Scan(self):
     img = utils.GetImgFromScreenShot()
     t = tm.Trainer(img)
     t.whiteCircles()
     current_page = getcurrentPage(img)
     for x, y in t.circlePoints:
         compareWithBackButton(log=None)
         time.sleep(1)
         tapnsleep((x, y), .5)
         img1 = utils.GetImgFromScreenShot()
         battle = checkIfBattle(img1)
         time.sleep(2.5)
         if battle:
             tapnsleep((150, 400), 2.5)
             battle = verifyBattle()
         if battle:
             self.current_battle = True
             root.info(battlemode % (x, y, current_page, "Starting Battle"))
             ScanForWord('ok', LOW_CORR)
             # time.sleep(1)
             utils.Tap(230, 690)
             Battle(x, y, current_page, self.CheckBattle)
         else:
             time.sleep(2)
             img = utils.GetImgFromScreenShot()
             logger = Logger(x, y, current_page, 'failure/BackButton',
                             "Checking, prompts or pop ups")
             backbutton = True
             while backbutton:
                 backbutton = compareWithBackButton(log=logger)
                 time.sleep(1)
             logger.updateMessage("failure/closeButton")
             closebutton = True
             while closebutton:
                 closebutton = ScanForClose(log=logger)
                 time.sleep(1)
             logger.updateMessage("success/Gift")
             okbutton = True
             while okbutton:
                 okbutton = ScanForWord('ok', log=logger)
                 time.sleep(1)
             # if utils.DiffImgPercent(img, img1) > .25:
         time.sleep(2)