from time import sleep
import pynput.mouse as mouse
import pynput.keyboard as keyboard
from threading import Thread
from datetime import datetime
from secrets import randbelow

k = keyboard.Controller()
m = mouse.Controller()

key_teleport="."
key_surge="f"
location_hub_portal=(1031,353)
location_aqueduct_portal=(835,808)
location_start_button=(1064,500)
compass=(1567,101)

sleep(5)

def click_at(coordinates: tuple[int,int]):
    m.position = coordinates
    m.click(mouse.Button.left)

def prevent_lobby():
    while True:
        random_milliseconds = randbelow(500_000)
        print(f"Sleeping for {random_milliseconds} milliseconds.")
        sleep(random_milliseconds / 1_000)
        print(f"{datetime.now()}: Preventing lobby")
        k.tap(" ")
        

Thread(target=prevent_lobby).start()

while True:
    k.tap(key_teleport)
    sleep(10)
    click_at(compass)
    k.tap(key_surge)
    sleep(2)
    click_at(location_hub_portal)
    sleep(12)
    click_at(location_aqueduct_portal)
    sleep(6)
    click_at(location_start_button)
    sleep(5)
    k.tap(key_surge)
    sleep(3500)
    