Detergent13 / tft-bot

Automate Teamfight Tactics (TFT) for token/mission farming. Updated for Set 11!
GNU Affero General Public License v3.0
81 stars 45 forks source link

here is some code #69

Closed CaS1ow closed 2 years ago

CaS1ow commented 2 years ago

I saw someone asking about play time and the number of games tft-bot played so i already coded it before here is my code it will show you "play time" and "end game count" after game end

def won_match():
    global gamecount
    global endtimer
    endtimer = time.time()
    gamecount += 1
    sec = (endtimer - starttimer)
    hours = sec // 3600
    sec = sec - hours*3600
    mu = sec // 60
    ss = sec - mu*60
    gamecount2 = str(gamecount)
    #result_list = str(datetime.timedelta(seconds=sec)).split(".")
    print("---------------------------------")
    print("game end")
    print("play time : ", int(float(hours)), "hour", int(float(mu)), "minutes", int(float(ss)), "second")
    print("end game count : ", gamecount2)
    print("---------------------------------")
    time.sleep(random.uniform(2.01712, 3.38302))

    end_match()

    time.sleep(random.uniform(4.51712, 5.08302))
    queue()

It will be convenient for users who use a resolution higher than the fhd resolution ex)QHD i am using QHD so i felt that I needed to fix the location of the game in the upper left corner to create insert item function here is code (your game will be move x:0 y:0 pos)

this is for def Start(): this will move lobby clients pos at x:0 y:0 pos

    try:
        hwnd = win32gui.FindWindow(None, "League of Legends")
        rect = win32gui.GetWindowRect(hwnd)
        x = rect[0]
        y = rect[1]
        win32gui.MoveWindow(hwnd,0,0,rect[2] - x,rect[3] - y,0)
    except:
        auto.alert("Game not found.\n")
        exit()
    print("queue")
    queue()

this is for game client (not a lobby client) windows 10 have hidden 7pixel size of bar at left side so i added if your using win10, it will -7 automately

    while not onscreen("./captures/loading.png"):
        time.sleep(random.uniform(1.09162, 1.44121)) 
        click_to("./captures/surak.png")
    print("game loading")
    global starttimer
    starttimer = time.time()
    hwnd = win32gui.FindWindow(None, "League of Legends (TM) Client")
    rect = win32gui.GetWindowRect(hwnd)
    x = rect[0]
    y = rect[1]
    if platform.release() == "10":
        win32gui.MoveWindow(hwnd,-7,0,rect[2] - x,rect[3] - y,0)
    else:
        win32gui.MoveWindow(hwnd,0,0,rect[2] - x,rect[3] - y,0)
    loading()