Beispiel #1
0
def danh():
    """ imgsearch temp  ->   next\n
                        //   danh   ->  danhtiep
    """
    # printdb('def danh')
    imgmanh = imagesearch(path_Scr + '\\screencap.png',
                          path_Scr + '\\longden.png', 0.77)
    time.sleep(1)
    # mạnh bỏ qua
    if imgmanh.find() >= 1:
        click_next()
        logging.info('Next')
        giaotranh()
    else:
        click_danh()
        #######################lỗi mạng######################
        time.sleep(30)
        screencap()
        error = imagesearch(path_Scr + '\\screencap.png',
                            path_Scr + '\\error.png', 0.88)
        # printdb('check lỗi ')
        if error.find() >= 1:  # check lỗi mạng
            check_loi_vethanh()
        else:
            time.sleep(cTimeWar)  # 40s
            # Rutlui()                  #opt1 check khiên --end (rỉa 1 khiên)
            DanhTiep()  # opt2 check nút hồi thành --end
Beispiel #2
0
def openAuto():
    call('adb shell input keyevent 3')
    time.sleep(2)
    screencap()
    imgiconAUTO = imagesearch(path_Scr + '//screencap.png',
                              path_Scr + '//autoicon2.png', 0.88)
    imgicondctq = imagesearch(path_Scr + '//screencap.png',
                              path_Scr + '//dctqicon.png', 0.88)
    posiconAuto = imgiconAUTO.find(showpos=True)[0]
    posiconDCTQ = imgicondctq.find(showpos=True)[0]
    for _ in range(3):
        if posiconAuto:
            posiconAutostr = ' '.join(str(x) for x in posiconAuto[::-1])
            posiconDCTQstr = ' '.join(str(x) for x in posiconDCTQ[::-1])
            call('adb shell input tap ' + posiconAutostr)
            logging.info('$ position AUTO in x.y: ', posiconAutostr)
            time.sleep(2)
            call('adb shell input keyevent 3')
            time.sleep(1)
            call('adb shell input tap ' + posiconDCTQstr)
            time.sleep(5)
            checkauto()
            break
        else:
            checkauto()
    else:
        logging.error('Auto icon notfound', exec_info=True)
        raise Exception('Auto icon notfound')
Beispiel #3
0
def check_loi_vethanh():
    logging.warning('Check lỗi về thành')
    """imgerror -> click trở về -> check hồi thành\n
        /-> imgquansu -> giao tranh\n
        /-> reset ccounterror -> wait10min
    """
    global cCountError
    cCountError = cCountError + 1
    if cCountError >= 20:
        logging.info('(o>>>>>> End by 20 count Error <<<<<<o)')
        Exit_NOX()
        exit_auto()
    else:  # check mất mạng
        screencap()
        error = imagesearch(path_Scr + '\\screencap.png',
                            path_Scr + '\\error.png', 0.88)
        if error.find() == True:  # check lỗi mạng
            call(['adb', 'shell', 'input', 'tap', '632', '444'])
            logging.warning('(o>>>>>> Count Error :  %s <<<<<<o)', cCountError)
            time.sleep(8)
            CheckHoiThanh()
            BoquaXacthuc()  # ***

        else:  # check lỗi dính giao diện
            call(['adb', 'shell', 'input', 'tap', '1250', '477'])
            screencap()
            quansu = imagesearch(path_Scr + '\\screencap.png',
                                 path_Scr + '\\quansu.png', 0.88)
            # giao tranh wait >=3 lần  ->  wait10min
            if quansu.find() >= 1:
                logging.info('(o>>>>>> Fail with something', cCountError,
                             ' <<<<<<o)')
                click_giaotranh()
                ############################################## Giống bước giaotranh() ################
                time.sleep(8)
                for _ in range(5):
                    screencap()
                    imgnext = imagesearch(path_Scr + '\\screencap.png',
                                          path_Scr + '\\next.png', 0.88)
                    # thấy next thì tới đánh
                    if imgnext.find() >= 1:
                        # printdb('lỗi dính và def đánh check mạnh yếu')
                        danh()
                        break
                    else:
                        time.sleep(2)
                        logging.info('Wait')
                else:
                    global cWait10min
                    cCountError = 0
                    logging.info('***reset count Error')
                    if cWait10min <= 3:
                        cWait10min = cWait10min + 1
                        Wait_10min()  # chết tướng
                    else:
                        Exit_NOX()
                        exit_auto()
Beispiel #4
0
def DanhTiep():
    """ ->  check nút hồi thành / checkloivethanh
            //nếu k lỗi thì check mua lính , số trận out -> dbomLinh / end
            //nếu k mua lính và cTranThang max -> đánh tiếp
            //nếu k có nút hồi thành thì cưỡng chế rutlui -> checkhoithanh -> boquaxacthuc
    """
    # printdb('def danh tiep')
    global cTranThang
    for x in range(0, 1):
        screencap()
        imgDanhTiep = imagesearch(path_Scr + '\\screencap.png',
                                  path_Scr + '\\hoithanh.png', 0.88)
        error = imagesearch(path_Scr + '\\screencap.png',
                            path_Scr + '\\error.png', 0.88)
        if error.find() >= 1:  # check lỗi mạng
            check_loi_vethanh()
            break
        elif imgDanhTiep.find() >= 1:
            cTranThang += 1
            logging.info('==[] Win  ', cTranThang)
            if cTranThang >= cTranThang2end:
                Exit_NOX()
                exit_auto()
            elif cTranThang in [3, 8, 11, 16]:  # Mua lính   cách  5 thằng
                logging.info('Count: ', cTranThang)
                # nút hồi thành
                call(['adb', 'shell', 'input', 'tap', '1100', '650'])
                time.sleep(8)
                CheckHoiThanh()
                dbomLinh()
                BoquaXacthuc()
                break
            else:  # đánh tiếp
                # time.sleep(5)
                logging.info('Continue')
                call(r'adb shell input tap 85 666')  # nút đánh tiếp
                time.sleep(0.5)
                call(['adb', 'shell', 'input', 'tap', '777', '450'])  # nút ok
                giaotranh()
                break
        else:
            time.sleep(2)
            logging.info('Wait ', x)
    else:
        cTranThang += 1
        logging.info('==[] Win  :', cTranThang)
        click_rutlui()
        time.sleep(5)
        if cTranThang >= cTranThang2end:
            Exit_NOX()
            exit_auto()
        else:
            logging.info('Continue')
            call(r'adb shell input tap 85 666')  # nút đánh tiếp
            time.sleep(0.5)
            call(['adb', 'shell', 'input', 'tap', '777', '450'])  # nút ok
            giaotranh()
Beispiel #5
0
def check_loi_vethanh():
    """
    """
    global cCountError
    cCountError += 1
    if cCountError >= 10:
        print('(o>>>>>>Lỗi lằm lỗi lốn 10 lần r ,nnghỉ <<<<<<o)')
        Exit_NOX()
        exit_auto()
    else:  #check mất mạng
        screencap()
        error = imagesearch(path_Scr + '\\screencap.png',
                            path_Scr + '\\error.png', 0.88)
        if error.find() == True:  #check lỗi mạng
            call(['adb', 'shell', 'input', 'tap', '632', '444'])
            print('(o>>>>>>Lỗi mạng lần ', cCountError, "\t\t <<<<<<o)")
            time.sleep(15)
            CheckDaHoiThanh()
        elif True:  #check lỗi dính giao diện
            call(['adb', 'shell', 'input', 'tap', '1250', '477'])
            screencap()
            quansu = imagesearch(path_Scr + '\\screencap.png',
                                 path_Scr + '\\quansu.png', 0.88)
            #giao tranh wait >=3 lần  ->  wait10min
            if quansu.find() >= 1:
                print('(o>>>>>>Lỗi dính giao diện lần', cCountError,
                      ' <<<<<<o)')
                click_giaotranh()
                time.sleep(8)
                for x in range(4):
                    screencap()
                    imgnext = imagesearch(path_Scr + '\\screencap.png',
                                          path_Scr + '\\next.png', 0.7)
                    # thấy next thì tới đánh
                    if imgnext.find() >= 1:
                        danh()
                        break
                    else:
                        time.sleep(2)
                        print('Wait')
                else:
                    cCountError = 0
                    global cWait10min
                    if cWait10min <= 3:
                        cWait10min = cWait10min + 1
                        Wait_10min()  # chết tướng
                    else:
                        Exit_NOX()
                        exit_auto()
Beispiel #6
0
def click_image(image, notfound='check_loi_vethanh'):
    """Find image in screen and click it and return "Ok"
    // else return "notfound" and do something
    exam:   
    click_image('warhouse.png')         
    click_image('warhouse.png' , 0) if not found image do nothing
    """
    logging.info('Tìm và click image : ', image)
    position = ()
    screencap()
    imgfind = imagesearch(path_Scr + '//screencap.png',
                          path_Scr + '//' + image, 0.77)
    logging.debug('$position : ', position)
    try:
        position = imgfind.find(showpos=True)[0]
        if position != None:
            position_to_string = ' '.join(str(x) for x in position[::-1])
            # logging.info(position_to_string)
            call('adb shell input tap ' + position_to_string)
            return "Ok"
    except (IndexError, Exception):
        logging.error('Image not found', exec_info=True)
        if notfound == 'check_loi_vethanh':
            check_loi_vethanh()
        elif notfound == 0:
            pass
        return "notfound"
    finally:
        del position
Beispiel #7
0
def lietruyen():
    logging.info('isLiettruyen')
    if isLiettruyen == 1:
        if click_image('chinhchien.png', 0) == "notfound":
            logging.info('Choise lietruyen and try again')
            exit_auto()
        time.sleep(0.5)
        call(['adb', 'shell', 'input', 'tap', '700',
              '600'])  # click xuất chiến
        time.sleep(8)
        for _ in range(5):
            screencap()
            imgthuquan = imagesearch(path_Scr + '\\screencap.png',
                                     path_Scr + '\\thuquan.png', 0.8)
            if imgthuquan.find() >= 1:
                click_danh()
                time.sleep(60)
                for _ in range(10):
                    if click_image('hoithanh.png', 0) == "Ok":
                        time.sleep(10)
                        lietruyen()
                        break
                else:
                    time.sleep(6)
                break
        else:
            time.sleep(3)
Beispiel #8
0
def _isLSB():  #check thành viên LSB
    # print('is lsb')
    call(['adb', 'shell', 'input', 'tap', '50', '50'])
    time.sleep(2)
    screencap()
    #covert .iconfig to lsb.png
    copyfile(path + '\\config.file', path_Scr + '\\lsb.png')
    real_license(path_Scr + '\\lsb.png')
    __lsb = imagesearch(path_Scr + '\\screencap.png', path_Scr + '\\lsb.png',
                        0.88)

    if __lsb.find() == 0:  #nếu k tìm ra
        # print('0')
        xaidoihihi()
    elif __lsb.find() >= 2:
        # print('2')
        xaidoihihi()
    elif __lsb.find() < 2 and __lsb.find() > 0:
        if hashfile(
                path_Scr + '\\lsb.png'
        ) == '00cb82f0eb81f01fe98ef7a80c35e0ceb3a844f2d236ff1158585ab8cb544914':
            # print('==LSB và vall == 65001')
            os.remove(path_Scr + '\\lsb.png')
            call(['adb', 'shell', 'input', 'tap', '1213', '47'])
            BoquaXacthuc()
        # else:print('khác LSB và vall')
    else:
        print('Lỗi xác thực rồi ')
        time.sleep(3)
Beispiel #9
0
def Hoithanh():
    """check nút hồi thành -> CheckDaHoiThanh"""
    global cTranThang
    for x in range(1, 7):
        screencap()
        imghoithanh = imagesearch(path_Scr + '\\screencap.png',
                                  path_Scr + '\\hoithanh.png', 0.88)
        if imghoithanh.find() >= 1:
            cTranThang += 1
            print('==[] Xong thằng thứ ', cTranThang)
            call(['adb', 'shell', 'input', 'tap', '1100', '650'])
            time.sleep(8)
            CheckDaHoiThanh()
            BoquaXacthuc()
            break
        elif True:
            time.sleep(5)
            print('Chờ đánh xong', x)
        else:
            print('Lỗi xác thực rồi')
    else:
        cTranThang += 1
        print('==[] Xong Thằng thứ :', cTranThang)
        click_rutlui()
        time.sleep(8)
        CheckDaHoiThanh()
        BoquaXacthuc()
Beispiel #10
0
def checkauto():
    screencap()
    imgAuto = imagesearch(path_Scr + '\\screencap.png',
                          path_Scr + '\\auto.png', 0.77)
    if imgAuto.find(showpos=True):
        global posAUTO
        posAUTO = imgAuto.find(showpos=True)[0]
        logging.info('Auto in y.x: ', posAUTO)
    else:
        logging.info('openAuto')
        openAuto()
Beispiel #11
0
def CheckHoiThanh():
    """ for check quansu -> break else checkloivethanh 
    """
    logging.info('check Hồi thành')
    for _ in range(10):
        screencap()
        quansu = imagesearch(path_Scr + '\\screencap.png',
                             path_Scr + '\\quansu.png', 0.88)
        if quansu.find() >= 1:
            break
        else:
            time.sleep(2)
            logging.info('Wait to come home')
    else:
        check_loi_vethanh()
Beispiel #12
0
def giaotranh():  #bấm gt -> đánh
    print('Tìm thành clone...')
    time.sleep(8)
    for x in range(6):
        screencap()
        imgnext = imagesearch(path_Scr + '\\screencap.png',
                              path_Scr + '\\next.png', 0.8)
        # imgnext = imagesearch(path_Scr+'\\screencap.png',path_Scr+'\\next.png',0.88)
        # thấy next thì chuyển
        if imgnext.find() >= 1:
            danh()
            break
        elif True:
            time.sleep(1)
            if x == 10:
                check_loi_vethanh()
        else:
            print('Lỗi xác thực rồi')
Beispiel #13
0
def CheckDaHoiThanh():  #Check quân sự -> break
    for x in range(1, 10):
        screencap()
        quansu = imagesearch(path_Scr + '\\screencap.png',
                             path_Scr + '\\quansu.png', 0.88)
        if quansu.find() >= 1:
            if cTranThang >= cTranThang2end:
                Exit_NOX()
                exit_auto()
            elif cTranThang in range(1, 56, 5):  #Mua lính   cách   5 thằng
                dbomLinh()
                break
            elif True:
                BoquaXacthuc()
        else:
            time.sleep(2)
            print('Đang Về Thành ')
    else:
        check_loi_vethanh()
Beispiel #14
0
def danh():  #check and kill     #về giao tranh hay auto
    imgmanh = imagesearch(path_Scr + '\\screencap.png',
                          path_Scr + '\\temp.png', 0.7)
    time.sleep(1)
    # mạnh bỏ qua
    if imgmanh.find() >= 1:
        click_next()
        print('Chọn thằng khác')
        giaotranh()
    elif True:
        click_danh()
        time.sleep(cTimeWar)
        # Rutlui()          #opt1 check khiên --end (rỉa 1 khiên)
        Hoithanh()  #opt2 check nút hồi thành --end
        # click_rutlui()    #opt3 chờ cTimeWar --End (đánh theo time chỉ định)
        # time.sleep(8)
        # CheckDaHoiThanh()
        # BoquaXacthuc()
    else:
        print('Lỗi xác thực rồi')
Beispiel #15
0
def giaotranh():
    """ sleep 8s \n
        imgnext -> danh 
                //checkloivethanh
    """
    # printdb('def giaotranh')
    time.sleep(8)
    logging.info('def giao tranh')
    for x in range(6):
        screencap()
        # thấy next thì chuyển
        imgnext = imagesearch(path_Scr + '\\screencap.png',
                              path_Scr + '\\next.png', 0.8)
        if imgnext.find() >= 1:
            # printdb('mạnh')
            danh()
            break
    else:
        if x == 5:
            check_loi_vethanh()
        else:
            time.sleep(2)