Ejemplo n.º 1
0
def check_queue(point):
    # get_screen()
    x = point.x
    y = point.y

    image = image_grab.grab(bbox=(x + 469, y + 234, x + 744, y + 424))
    image.save(get_analyzable_relative_path() + "queue_screenshot.png")
    queue_screenshot = Image.open(get_analyzable_relative_path() +
                                  "queue_screenshot.png")
    queue_check = Image.open(get_button_relative_path() + "queue_check.PNG")

    popped = False
    while not popped:
        popped = compare_images(queue_screenshot, queue_check)
        image = image_grab.grab(bbox=(x + 468, y + 234, x + 743, y + 424))
        image.save(get_analyzable_relative_path() + "queue_screenshot.png")
        queue_screenshot = Image.open(get_analyzable_relative_path() +
                                      "queue_screenshot.png")
        time.sleep(.5)

    # Accept queue
    # click(Point(x + 600, y + 540))

    # Decline queue
    click(Point(x + 600, y + 600))
Ejemplo n.º 2
0
def find_points_of_interest_by_color(tested_area, master_color_tuple,
                                     cooldown_radius):
    interested_locations = []
    # 162, 254, 254
    width, height = tested_area.size
    tested_pixels = tested_area.load()
    data = []

    for y in range(height):
        for x in range(width):
            if not is_a_close_color(tested_pixels[x, y], master_color_tuple):
                data.append((0, 0, 0))
            else:
                data.append((tested_pixels[x, y][0], tested_pixels[x, y][1],
                             tested_pixels[x, y][2]))

    image = Image.new('RGB', (width, height))
    image.putdata(data)

    image_pixels = image.load()
    width, height = image.size

    for y in range(height):
        for x in range(width):
            # Stay away from out of bounds errors
            if x == 0 or x == width - 1 or y == 0 or y == height - 1:
                continue

            # Check if close to already existing POI
            if is_in_radius(Point(x, y), interested_locations,
                            cooldown_radius):
                continue

            if not pixel_is_black(image_pixels[x, y]):
                count = 0
                surrounding = [
                    image_pixels[x, y - 1], image_pixels[x - 1, y],
                    image_pixels[x + 1, y], image_pixels[x, y + 1]
                ]
                for surround in surrounding:
                    if is_a_close_color(surround, master_color_tuple):
                        count += 1

                if count > 2:
                    interested_locations.append(Point(x, y))

    return interested_locations
Ejemplo n.º 3
0
def find_pixels_of_interest_for_starting_circle(tested_area):
    to_be_averaged = find_points_of_interest_by_color(tested_area, (254, 254, 145), 50)

    x, y = 0, 0
    for point in to_be_averaged:
        x += point.x
        y += point.y

    x /= len(to_be_averaged)
    y /= len(to_be_averaged)

    return Point(int(x), int(y))
def set_bench_clickable_locations():
    points = []
    row_x = 0
    base_x = 430
    base_y = 775
    slot_offset = 120

    for x in range(BENCH_SLOTS):
        points.append(Point(base_x + (slot_offset * row_x), base_y))
        row_x += 1

    return points
Ejemplo n.º 5
0
def click_through_to_game(point):
    # x, y is the locations of play button
    x = point.x
    y = point.y

    # This clicks on the play button
    click(Point(x + 55, y + 10))

    # This clicks on the Team Fight Tactics part of game modes
    time.sleep(.5)
    click(Point(x + 840, y + 250))

    # This clicks on the confirm for the game mode
    time.sleep(.5)
    click(Point(x + 500, y + 666))

    # This clicks on the "Find Match" button once in a TFT lobby.
    time.sleep(3)
    click(Point(x + 500, y + 666))

    # This checks if a queue is pops and then clicks on (Accept!/Decline)
    check_queue(point)
Ejemplo n.º 6
0
def get_colors():
    cordinate = Point(170, 140)
    return [
        (CHARACTER_IMAGE_LIST[CHARACTER_TIER_INDEXES[0]].load()[cordinate.x,
                                                                cordinate.y]),
        CHARACTER_IMAGE_LIST[CHARACTER_TIER_INDEXES[1]].load()[cordinate.x,
                                                               cordinate.y],
        CHARACTER_IMAGE_LIST[CHARACTER_TIER_INDEXES[2]].load()[cordinate.x,
                                                               cordinate.y],
        CHARACTER_IMAGE_LIST[CHARACTER_TIER_INDEXES[3]].load()[cordinate.x,
                                                               cordinate.y],
        CHARACTER_IMAGE_LIST[CHARACTER_TIER_INDEXES[4]].load()[cordinate.x,
                                                               cordinate.y]
    ]
def set_board_clickable_locations():
    points = []
    row_x = 0
    row_y = 0
    base_x = 560
    base_y = 490
    slot_offset = Point(140, 85)

    for y in range(BOARD_SIZE_HEIGHT):
        for x in range(BOARD_SIZE_WIDTH):
            if row_y % 2 == 1:
                # Apply offset
                points.append(
                    Point((base_x - 70) + (slot_offset.x * row_x),
                          base_y + (slot_offset.y * row_y)))
            else:
                points.append(
                    Point(base_x + (slot_offset.x * row_x),
                          base_y + (slot_offset.y * row_y)))
            row_x += 1
        row_x = 0
        row_y += 1

    return points
Ejemplo n.º 8
0
def compare_images_and_get_location_strictly(tested, master, variance):
    tested_pixels = tested.load()
    master_pixels = master.load()

    index = 0
    for x in range(tested.size[0]):
        print("still going... at " + str(index))
        index += 1
        for y in range(tested.size[1]):
            if compare_pixels_strictly(tested_pixels[x, y], master_pixels[0, 0], variance):
                cropped_image = tested.crop((x, y, x + master.size[0], y + master.size[1]))
                if compare_images(cropped_image, master):
                    cropped_image.show()
                    return Point(x, y)

    return None
Ejemplo n.º 9
0
def find_play_button():
    get_screen()
    screen_image = Image.open(get_analyzable_relative_path() + "screen.png")
    screen = screen_image.load()

    play_button_image = Image.open(get_button_relative_path() +
                                   "play_button.PNG")
    play_button_pixels = play_button_image.convert('RGB')
    play_button_pixels = play_button_pixels.load()

    for x in range(get_screensize()[0]):
        for y in range(get_screensize()[1]):
            if compare_pixels_strictly(screen[x, y], play_button_pixels[0, 0],
                                       25):
                cropped_image = screen_image.crop((x, y, x + 154, y + 38))
                if compare_images(cropped_image, play_button_image):
                    return Point(x, y)

    return None
Ejemplo n.º 10
0
from TeamFightTacticsBot.Structures.PlayingBoard import PlayingBoard

CHAMPION_MAX_LEVEL = 3

CAROUSEL_CHAMPION_COUNT = 9

BENCH_SLOTS = 9
BENCH_SLOT_CLICKABLE_LOCATIONS = []

BOARD_SIZE_WIDTH = 7
BOARD_SIZE_HEIGHT = 3
BOARD_SLOT_CLICKABLE_LOCATIONS = []

SHOP_SIZE = 5
SHOP_SLOT_CLICKABLE_LOCATIONS = [
    Point(500, 970),
    Point(730, 970),
    Point(920, 970),
    Point(1150, 970),
    Point(1320, 970)
]

STREAK_BONUS_GOLD_THRESHOLD = [2, 4, 7]

# In game variables
PLAYER_LEVEL = 1
PLAYER_XP = 0
PLAYER_BOARD = PlayingBoard("Me")

CURRENT_STAGE = 1
CURRENT_ROUND = 1