Пример #1
0
def continue_button():
    sw, sh = win_util.get_screen_size()
    x = sw // 2
    y = int(sh * 0.65)
    win_util.click(x, y)
    sleep(1)
    win_util.click(x, y)
Пример #2
0
def solve_needy_vent(image, mod_pos):
    if not needy_features.is_active(image):
        log("Needy Vent is not active.", config.LOG_DEBUG, "Needy Vent")
        return
    mod_x, mod_y = mod_pos
    button_y, button_x = needy_vent_solver.solve(image)
    win_util.click(button_x + mod_x, button_y + mod_y)
Пример #3
0
def solve_needy_knob(image, mod_pos):
    mod_x, mod_y = mod_pos
    dial_x, dial_y = mod_x + 150, mod_y + 161
    num_turns = needy_knob_solver.solve(image)
    for _ in range(num_turns):
        win_util.click(dial_x, dial_y)
        sleep(0.3)
Пример #4
0
def solve_complicated_wires(image, mod_pos, side_features):
    mod_x, mod_y = mod_pos
    wires_to_cut, coords = compl_wires_solver.solve(image, side_features)
    for i, cut in enumerate(wires_to_cut):
        if cut:
            y, x = coords[i]
            win_util.click(mod_x + x, mod_y + y)
            sleep(0.3)
Пример #5
0
def solve_whos_on_first(image, char_model, mod_pos):
    mod_x, mod_y = mod_pos
    for i in range(3):
        coords = whos_first_solver.solve(image, char_model)
        y, x = coords
        win_util.click(x + mod_x, y + mod_y)
        if i < 2:
            sleep(3.5)
        image = convert_to_cv2(screenshot_module()[0])
Пример #6
0
def solve_symbols(image, mod_pos, symbol_model):
    mod_x, mod_y = mod_pos
    coords = symbols_solver.solve(image, symbol_model)
    if coords is None:
        log("WARNING: Could not solve symbols.", config.LOG_WARNING)
        return
    for y, x in coords:
        win_util.click(mod_x + x, mod_y + y)
        sleep(0.3)
Пример #7
0
def solve_morse(image, mod_pos):
    mod_x, mod_y = mod_pos
    presses, frequency = morse_solver.solve(image, screenshot_module)
    log(f"Morse frequency: {frequency}.", config.LOG_DEBUG, "Morse")
    button_x, button_y = mod_x + 154, mod_y + 236
    inc_btn_x, inc_btn_y = mod_x + 240, mod_y + 170
    for _ in range(presses):
        win_util.click(inc_btn_x, inc_btn_y)
        sleep(0.3)
    win_util.click(button_x, button_y)
Пример #8
0
def solve_password(image, char_model, mod_pos):
    mod_x, mod_y = mod_pos
    submit_x, submit_y = mod_x + 154, mod_y + 254
    # Use lambda function to translate 'image-local' clicks
    # from the password solver into 'screen-local' coordinates.
    click_func = lambda x, y: win_util.click(mod_x + x, mod_y + y)
    success = password_solver.solve(image, char_model, screenshot_module, click_func)
    if success:
        win_util.click(submit_x, submit_y)
    else:
        log(f"WARNING: Could not solve 'Password'.", config.LOG_WARNING)
Пример #9
0
def flip_bomb(SW, SH):
    mid_x = SW // 2
    mid_y = SH // 2
    win_util.click(SW - 100, 100, btn="right")
    sleep(0.5)
    win_util.click(mid_x, mid_y + (mid_y // 8))
    sleep(0.2)
    win_util.mouse_down(mid_x, mid_y, btn="right")
    sleep(0.5)
    win_util.mouse_move(SW - int(SW / 4.4), mid_y + (mid_y // 9))
    sleep(0.5)
Пример #10
0
def solve_memory(image, char_model, mod_pos):
    mod_x, mod_y = mod_pos
    history = []
    for i in range(5):
        coords, label, position = memory_solver.solve(image, char_model, history)
        history.append((label, position))
        y, x = coords
        win_util.click(x + mod_x, y + mod_y)
        if i < 4:
            sleep(3.5)
        image = convert_to_cv2(screenshot_module()[0])
Пример #11
0
def solve_simon(image, mod_pos, side_features):
    mod_x, mod_y = mod_pos
    num = 1
    while not simon_solver.is_solved(image):
        btn_coords = simon_solver.solve(image, screenshot_module, side_features, num)
        for coords in btn_coords:
            button_y, button_x = coords
            win_util.click(mod_x + button_x, mod_y + button_y)
            sleep(0.5)
        num += 1
        SC, _, _ = screenshot_module()
        image = convert_to_cv2(SC)
Пример #12
0
def solve_wire_sequence(image, mod_pos):
    mod_x, mod_y = mod_pos
    button_x, button_y = 128 + mod_x, 248 + mod_y
    color_hist = [0, 0, 0]
    for i in range(4):
        wires_to_cut, color_hist, coords = wire_seq_solver.solve(image, color_hist)
        for j, cut in enumerate(wires_to_cut):
            if cut:
                y, x = coords[j]
                win_util.click(mod_x + x, mod_y + y)
                sleep(0.5)
        win_util.click(button_x, button_y)
        if i < 3:
            sleep(1.8)
        image = convert_to_cv2(screenshot_module()[0])
Пример #13
0
def solve_button(image, mod_pos, side_features, character_model, duration):
    mod_x, mod_y = mod_pos
    hold = button_solver.solve(image, side_features, character_model)
    button_x, button_y = mod_x + 125, mod_y + 175
    if not hold:
        log(f"Tapping button.", config.LOG_DEBUG, "Button")
        win_util.click(button_x, button_y)
        sleep(0.5)
    else:
        log(f"Holding button...", config.LOG_DEBUG, "Button")
        win_util.mouse_move(button_x, button_y)
        win_util.mouse_down(button_x, button_y)
        sleep(0.9)  # 48 frames until strip lights up.
        SC, _, _ = screenshot_module()
        image = convert_to_cv2(SC)
        pixel = (184, 255)
        release_time = button_solver.get_release_time(image, pixel)
        log(f"Release button at {release_time}", config.LOG_DEBUG, "Button")
        release_mouse_at(release_time, duration, button_x, button_y)
Пример #14
0
def restart_level(level):
    SW, SH = win_util.get_screen_size()
    win_util.click(int(SW * 0.9), int(SH * 0.8), btn="right")
    sleep(1)
    win_util.click(int(SW * 0.73), int(SH * 0.65))
    sleep(1)
    win_util.click(int(SW * 0.73), int(SH * 0.45))
    sleep(2)
    win_util.click(int(SW * 0.52), int(SH * 0.53))
    sleep(0.8)
    inspect_bomb.select_level(level)
    sleep(0.5)
Пример #15
0
def solve_maze(image, mod_pos):
    mod_x, mod_y = mod_pos
    up_x, up_y = (mod_x + 143, mod_y + 36)
    down_x, down_y = (mod_x + 143, mod_y + 263)
    left_x, left_y = (mod_x + 27, mod_y + 144)
    right_x, right_y = (mod_x + 253, mod_y + 144)
    N = maze_solver.DIRECTIONS.North
    S = maze_solver.DIRECTIONS.South
    E = maze_solver.DIRECTIONS.East
    W = maze_solver.DIRECTIONS.West
    path = maze_solver.solve(image)
    for direction in path:
        if direction == N:
            win_util.click(up_x, up_y)
        elif direction == S:
            win_util.click(down_x, down_y)
        elif direction == W:
            win_util.click(left_x, left_y)
        elif direction == E:
            win_util.click(right_x, right_y)
        sleep(0.3)
Пример #16
0
def inspect_bomb(num_modules=None):
    sw, sh = win_util.get_screen_size()
    mid_x = sw // 2
    mid_y = sh // 2
    win_util.click(mid_x, mid_y + (mid_y // 8))
    sleep(0.5)
    # Inspect front of bomb.
    front_img = screenshot(460, 220, 1000, 640)
    sleep(0.2)
    # Rotate bomb.
    win_util.mouse_down(mid_x, mid_y, btn="right")
    sleep(0.2)
    # Inspect right side.
    right_img = inspect_side(sw - int(sw / 2.74), mid_y + int(mid_y / 8), 755,
                             60, 480, 900)
    # Inspect left side.
    left_img = inspect_side(int(sw / 2.76), mid_y + int(mid_y / 8), 755, 60,
                            480, 900)
    # Inspect top side.
    top_img = inspect_side(int(sw / 2.75), sh, 720, 0, 480, sh)
    # Inspect bottom side.
    bottom_img = inspect_side(int(sw / 2.75), 0, 720, 0, 480, sh)
    # Inspect back of bomb.
    win_util.mouse_up(mid_x, mid_y, btn="right")
    sleep(0.5)
    return_tupl = (front_img, left_img, right_img, top_img, bottom_img)
    if num_modules is None or num_modules > 5:
        flip_bomb(sw, sh)
        back_img = screenshot(460, 220, 1000, 640)
        sleep(0.4)
        win_util.mouse_up(mid_x, mid_y, btn="right")
        return_tupl = (back_img, ) + return_tupl
    else:
        win_util.click(200, 200, btn="right")
        sleep(0.4)
        win_util.click(mid_x, mid_y + (mid_y // 8))
        sleep(0.5)
    return return_tupl
Пример #17
0
def select_level(level):
    win_util.click(int(SW * 0.55), LEVEL_COORDS[level])
Пример #18
0
def deselect_module():
    x = 300
    y = 300
    win_util.click(x, y, btn="right")
    sleep(0.5)
Пример #19
0
def select_module(module_index):
    x, y = get_module_coords(module_index)
    win_util.click(x, y)
    sleep(1)
Пример #20
0
def select_bombs_menu():
    sw, sh = win_util.get_screen_size()
    x = sw // 2
    y = int(sh * 0.56)
    win_util.click(x, y)
Пример #21
0
def start_level():
    """
    Click the 'Start Level' button, after a level has been selected.
    """
    SW, SH = win_util.get_screen_size()
    win_util.click(int(SW - SW / 2.6), int(SH - SH / 3.3))
Пример #22
0
def solve_wires(image, mod_pos, side_features):
    mod_x, mod_y = mod_pos
    result, coords = wire_solver.solve(image, side_features)
    log(f"Cut wire at {result}", config.LOG_DEBUG)
    wire_y, wire_x = coords[result]
    win_util.click(mod_x + wire_x, mod_y + wire_y)
Пример #23
0
def next_level_page():
    sw, sh = win_util.get_screen_size()
    win_util.click(int(sw * 0.65), int(sh * 0.70))