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 #68

Closed CaS1ow closed 1 year ago

CaS1ow commented 2 years ago

I saw someone asking about showing play time and the number of games i already coded it before, I felt the need to share it. here is my code it will show you "play time" and "end game count" after the 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()

The contents below are unnecessary for users of FHD resolution. It will be convenient for users who use a resolution higher than the fhd resolution ex)QHD, WQHD 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 client's pos at "x:0 y:0 pos" when you start bot

    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 detect winver method, 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()

please understand my bad English 😢 I hope it helps other people 🙏

Detergent13 commented 1 year ago

Mostly added with #71. Thanks for your contributions!