Beispiel #1
0
def run():
    utilities.set_status('Starting bot...')

    # If league is already in game, finish the game
    if utilities.is_league_in_game():
        complete_game()

    # Otherwise, restart client and wait for login
    else:
        restart_client()
        utilities.set_status('Awaiting login...')
        await_login()

        # Start queueing up
        globals.time_since_last_click = timer()
        utilities.set_status('Queueing for a game...')

    # Start loop
    while True:
        pause_if_needed()

        # If game has started, complete the game
        if utilities.is_league_in_game():
            complete_game()
            continue

        # Check for daily play rewards
        if attempt_to_click_on(pictures.daily_play, None, click=False):
            daily_play()

        # Check for level up rewards
        attempt_to_click_on(pictures.ok, None)

        # Check for clash notification
        attempt_to_click_on(pictures.clash, None)

        # Check if champ select bugged
        attempt_to_click_on(pictures.ok_champ_select_bug, None)

        # Check if we're in champ select
        if attempt_to_click_on(pictures.choose_champ,
                               regions.choose_champ,
                               click=False):
            champ_select()

        # Check for other buttons
        attempt_to_click_on(pictures.play_button, regions.play_button)
        attempt_to_click_on(pictures.party, regions.party_button)
        attempt_to_click_on(pictures.coop_vs_ai, regions.coop_vs_ai)
        attempt_to_click_on(pictures.intermediate_bots,
                            regions.intermediate_bots)
        attempt_to_click_on(pictures.confirm, regions.confirm)
        attempt_to_click_on(pictures.find_match, regions.find_match)
        attempt_to_click_on(pictures.accept, regions.accept)
        attempt_to_click_on(pictures.play_again, None)

        # If 2 minutes has elapsed without doing anything, restart client
        if did_timeout(120):
            client_stuck()
Beispiel #2
0
def complete_game():
    utilities.set_status('Waiting for game to start...')

    # Wait until recall is visible, then we know we're in game
    while not attempt_to_click_on(
            pictures.recall, None, is_game=True, click=False):
        pause_if_needed()

    # Lock the screen once we're in game
    lock_screen()

    # Click mid
    utilities.set_status('Running it down mid...')
    game_flag = 1
    while game_flag:
        pause_if_needed()

        # If we're out of game
        if not utilities.is_league_in_game():
            game_flag = 0
            continue

        # Get the location of league window
        try:
            rect = utilities.get_game_coords()
        except Exception:
            continue
        x = rect[0] + 1260
        y = rect[1] + 592

        # Right click down mid every 1 second
        try:
            win32api.SetCursorPos((x, y))
            win32api.mouse_event(win32con.MOUSEEVENTF_MIDDLEDOWN, x, y, 0, 0)
            win32api.mouse_event(win32con.MOUSEEVENTF_MIDDLEUP, x, y, 0, 0)
            time.sleep(1)
        except Exception:
            continue

    # Once the game is finished
    increment_games()

    # Check to see if the bot is finished all games
    if globals.number_of_games_finished == globals.number_of_games_to_play:
        stop_bot()
        return

    # Skip honor
    globals.time_since_last_click = timer()
    while not attempt_to_click_on(pictures.skip_honor, None):
        if did_timeout(30):
            client_stuck()
            return
        time.sleep(1)

    # Requeue for another game
    utilities.set_status("Currently queueing for a game...")
Beispiel #3
0
def move_windows():
    try:
        if utilities.is_client_open():
            hwnd = win32gui.FindWindow(None, 'League of Legends')
            win32gui.MoveWindow(hwnd, 350, 180, 1280, 720, True)
        if utilities.is_league_in_game():
            hwnd = win32gui.FindWindow(None, 'League of Legends (TM) Client')
            win32gui.MoveWindow(hwnd, 600, 180, 1280, 720, True)
    except Exception:
        return
Beispiel #4
0
def complete_game():
    utilities.set_status('Waiting for game to start...')

    # Wait until recall button is visible, then we know we're in game
    while not attempt_to_click_on(
            pictures.recall, None, is_game=True, click=False):
        pause_if_needed()

    # Click mid
    utilities.set_status('Running it down mid...')
    while True:
        pause_if_needed()

        # If we're out of game
        if not utilities.is_league_in_game():
            break

        # If the camera isn't locked, lock it
        if attempt_to_click_on(pictures.lock_camera,
                               None,
                               is_game=True,
                               click=False):
            lock_screen()

        # Get the location of league window
        try:
            rect = utilities.get_game_coords()
        except Exception:
            continue
        x = rect[0] + 1260
        y = rect[1] + 592

        # Right click down mid every 3 seconds
        try:
            win32api.SetCursorPos((x, y))
            win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, x, y, 0, 0)
            win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, x, y, 0, 0)
            time.sleep(3)
        except Exception:
            continue

    # Once the game is finished
    increment_games()

    # Skip honor
    globals.time_since_last_click = timer()
    while not attempt_to_click_on(pictures.skip_honor, None):
        if did_timeout(30):
            client_stuck()
            return
        time.sleep(1)

    # Requeue for another game
    utilities.set_status("Queueing for a game...")
Beispiel #5
0
def await_login():
    while True:
        pause_if_needed()
        if attempt_to_click_on(pictures.play_button, regions.play_button):
            return
        elif attempt_to_click_on(pictures.party, regions.party_button):
            return
        elif attempt_to_click_on(pictures.daily_play, None):
            daily_play()
            return
        elif utilities.is_league_in_game():
            complete_game()
            return
        elif attempt_to_click_on(pictures.riot_client_play,
                                 None,
                                 is_riot_client=True):
            pass
Beispiel #6
0
def run():
    while globals.number_of_games_to_play == -1:
        time.sleep(0.1)
    if globals.number_of_games_to_play is None:
        return
    print('Current status: Starting bot...')
    utilities.save_user_files()
    utilities.set_bot_files()
    # If league is in game
    if utilities.is_league_in_game():
        if globals.stop_flag:
            return
        focus_game_or_client()
        click_mid()
    # Otherwise
    else:
        if globals.stop_flag:
            return
        restart_client()
        print('Current status: Awaiting login...')
        client_open = False
        await_login()
    globals.time_since_last_click = timer()
    print('Current status: Queueing for a game...')
    while True:
        if globals.stop_flag:
            return
        # If bot is paused, wait 1 second then try again
        if not globals.go_flag:
            time.sleep(1)
            globals.time_since_last_click = timer()
            continue
        # If we are in game, simply execute the ClickMid() function
        if utilities.is_league_in_game():
            click_mid()
            continue
        # Check for daily play rewards
        if attempt_to_click_on(pictures.daily_play, daily_play_color):
            daily_play()
        # Check for level up rewards
        attempt_to_click_on(ok_levelup_coords, ok_levelup_color)

        # Check for buttons
        AttemptToClickOnPix(play_coords, play_party_color)
        AttemptToClickOnPix(party_coords, play_party_color)
        AttemptToClickOnPix(coop_vs_ai_coords, coop_vs_ai_color)
        AttemptToClickOnPix(find_match_coords, find_match_color)
        AttemptToClickOnPix(intermediate_coords, intermediate_color)
        AttemptToClickOnPix(confirm_coords, confirm_color)
        AttemptToClickOnPix(find_match_coords, find_match_color)
        AttemptToClickOnPix(accept_coords, accept_color)
        if (LockInChampion()):
            SetStatus("Current status: In champion select...")
            while (AttemptToClickOnPix(champ_locked_coords, champ_locked_color, click=False)):
                time.sleep(1)
        AttemptToClickOnPix(play_again_coords, play_again_color)
        AttemptToClickOnPix(find_match_coords, find_match_color)

        # If 2 minutes has elapsed without doing anything, restart client
        if (DidTimeout(120)):
            ClientStuck()
Beispiel #7
0
def focus_game_or_client():
    if utilities.is_league_in_game():
        win32gui.SetForegroundWindow(
            find_window(title='League of Legends (TM) Client'))
    elif utilities.is_client_open():
        win32gui.SetForegroundWindow(find_window(title='League of Legends'))