def shouldAttack():
    troop_count_max = tes.image_to_string(
        process_img(grab_screen(region=(144, 220, 184, 237))))
    current_troop_count = tes.image_to_string(
        process_img(grab_screen(region=(100, 220, 138, 238))))
    spy_count_max = tes.image_to_string(
        Utils.convertPixels(
            process_img(grab_screen(region=(145, 272, 192, 293))), 100, 255))
    spy_current_troop = tes.image_to_string(
        Utils.convertPixels(
            process_img(grab_screen(region=(90, 272, 139, 293))), 100, 255))
    print("Current troop count: " + current_troop_count)
    print("Current Spy count: " + spy_current_troop)
    try:
        if ('(' not in current_troop_count or '(' not in troop_count_max
            ) and int(76200) <= int(current_troop_count):
            return True
    except ValueError:
        print('Troop count messed up!')

    try:
        spy = int(spy_current_troop)
        if '(' not in spy_current_troop and ((spy >= 730000) and
                                             (spy <= 800000)):
            return True
    except ValueError:
        print('Assassin count messed up!')
    return False
示例#2
0
def main():
    last_time = time.time()
    while True:
        #screen = grab_screen(region=(20, 40, 1900, 900))
        img = process_img(grab_screen(region=(170, 590, 245, 615)))
        #ns = cv2.line(screen, (1100, 280), (1175, 280), (245,0,0), 5)
        #img = cv2.cvtColor(screen, cv2.COLOR_BGR2GRAY)
        #print(tes.image_to_string(process_img(grab_screen(region=(820, 290, 1100, 335)))))
        cv2.imshow(
            'window',
            Utils.convertPixelsOpposite(
                Utils.convertPixelsOpposite(
                    process_img(grab_screen(region=(1695, 305, 1813, 326))),
                    180, 255), 180, 0))
        cv2.imshow(
            'window2',
            np.invert(
                Utils.convertPixelsOpposite(
                    process_img(grab_screen(region=(1695, 305, 1813, 326))),
                    240, 0)))
        print("spy: " + tes.image_to_string(
            Utils.convertPixels(
                np.invert(
                    process_img(grab_screen(region=(1695, 305, 1813,
                                                    326)))), 140, 252)))
        #ns = np.asarray(img)
        print('Clan: ' + getClan())
        #if(shouldAttack()):
        #print("Attacking")
        #shell = win32com.client.Dispatch("WScript.Shell")
        #shell.SendKeys('%')
        #win32gui.SetForegroundWindow(utils.getFireFox())
        if cv2.waitKey(25) & 0xFF == ord('q'):
            cv2.destroyAllWindows()
            break
示例#3
0
def custom_get_positions(region=None):
    hwin = Utils.getFireFox()
    if region:
        left, top, x2, y2 = region
        width = x2 - left + 1
        height = y2 - top + 1
    else:
        width = win32api.GetSystemMetrics(win32con.SM_CXVIRTUALSCREEN)
        height = win32api.GetSystemMetrics(win32con.SM_CYVIRTUALSCREEN)
        left = win32api.GetSystemMetrics(win32con.SM_XVIRTUALSCREEN)
        top = win32api.GetSystemMetrics(win32con.SM_YVIRTUALSCREEN)

    hwindc = win32gui.GetWindowDC(hwin)
    srcdc = win32ui.CreateDCFromHandle(hwindc)
    memdc = srcdc.CreateCompatibleDC()
    bmp = win32ui.CreateBitmap()
    bmp.CreateCompatibleBitmap(srcdc, width, height)
    memdc.SelectObject(bmp)
    memdc.BitBlt((0, 0), (width, height), srcdc, (left, top), win32con.SRCCOPY)

    signedIntsArray = bmp.GetBitmapBits(True)
    img = np.fromstring(signedIntsArray, dtype='uint8')
    img.shape = (height, width, 4)

    srcdc.DeleteDC()
    memdc.DeleteDC()
    win32gui.ReleaseDC(hwin, hwindc)
    win32gui.DeleteObject(bmp.GetHandle())
    return img
示例#4
0
def main():
    keypressed = SPACE
    timesin = 0
    while True:
        # screen = grab_screen(region=(20, 40, 1900, 900))
        # ns = cv2.rectangle(screen, (170, 182), (123, 200), (0, 0, 255), 2)
        # img = cv2.cvtColor(ns, cv2.COLOR_BGR2GRAY)
        # cv2.imshow('window', img)
        current_window = win32gui.GetForegroundWindow()
        start = time.time()
        img = custom_get_positions(region=(383, 157, 1530, 1025))
        if (current_window == Utils.getFireFox()):
            ball_x = get_ball_pos_x(img)
            player_x = get_player_pos_x(img)
            newimg = draw_contours(img)
            newimg = cv2.resize(newimg, (1300, 700))
            cv2.imshow('window', newimg)
            if (ball_x + 28 > player_x and ball_x - 28 < player_x):
                PressKey(SPACE)
            else:
                if (player_x > ball_x):
                    PressKey(LEFT)
                    PressKey(SPACE)
                elif (player_x < ball_x):
                    PressKey(RIGHT)
                    PressKey(SPACE)
            if cv2.waitKey(25) & 0xFF == ord('q'):
                cv2.destroyAllWindows()
                break
    time.sleep(12)
def main():
    attacks = 0
    while True:
        #screen = grab_screen(region=(20, 40, 1900, 900))
        #ns = cv2.rectangle(screen, (170, 182), (123, 200), (0, 0, 255), 2)
        #img = cv2.cvtColor(ns, cv2.COLOR_BGR2GRAY)
        #cv2.imshow('window', img)
        print("Clan: " + getClan())
        if (len(getClan()) > 2 and 'No clan' not in getClan()):
            if (hasEb()):
                if (shouldAttack()):
                    print("Attacking")
                    current_window = win32gui.GetForegroundWindow()
                    shell = win32com.client.Dispatch("WScript.Shell")
                    shell.SendKeys('%')
                    win32gui.SetForegroundWindow(Utils.getFireFox())
                    Attack()
                    attacks += 1
                    shell.SendKeys('%')
                    win32gui.SetForegroundWindow(current_window)
                    print('times attacked: ' + str(attacks))
                if cv2.waitKey(25) & 0xFF == ord('q'):
                    cv2.destroyAllWindows()
                    break
        time.sleep(50)
    print('times attacked: ' + str(attacks))
def hasEb():
    checkeb = tes.image_to_string(
        np.invert(
            Utils.convertPixelsOpposite(
                process_img(grab_screen(region=(1695, 305, 1813, 326))), 240,
                0)))
    if 'view' in checkeb:
        print("Eb currently available!")
        return True
    else:
        print("Eb not currently available")
        return False
def getClan():
    clan = tes.image_to_string(
        Utils.convertPixels(
            np.invert(process_img(grab_screen(region=(170, 590, 245, 615)))),
            90, 200))
    return clan