""" Handles sending input to the game, coords contain a cartesian ordered pair (x, y) """ import random from time import sleep from pynput.mouse import Controller, Button from pynput.keyboard import Key, Controller as KeyboardController mouse = Controller() keyboard = KeyboardController() def left_click(coords: tuple) -> None: """Simulate a left click at the specified coordinates. Args: coords (tuple): A tuple containing cartesian coordinates (x, y). """ offset: int = random.randint(-3, 3) mouse.position = (coords[0] - offset, coords[1] - offset) mouse.press(Button.left) sleep(0.15) mouse.release(Button.left) sleep(0.15) def right_click(coords: tuple) -> None: """Simulate a right click at the specified coordinates. Args: coords (tuple): A tuple containing cartesian coordinates (x, y). """ offset: int = random.randint(-3, 3) mouse.position = (coords[0] - offset, coords[1] - offset) mouse.press(Button.right) sleep(0.15) mouse.release(Button.right) sleep(0.15) def press_e(coords: tuple) -> None: """Simulate pressing the 'e' key at the specified coordinates. Args: coords (tuple): A tuple containing cartesian coordinates (x, y). """ offset: int = random.randint(-3, 3) mouse.position = (coords[0] - offset, coords[1] - offset) keyboard.press('e') sleep(0.15) keyboard.release('e') sleep(0.15) def press_s() -> None: """Presses s. Pressing s stop the movement of the tactician.""" keyboard.press('s') sleep(0.1) keyboard.release('s') sleep(0.1) def move_mouse(coords: tuple) -> None: """Move the mouse to the specified coordinates. Args: coords (tuple): A tuple containing cartesian coordinates (x, y). """ mouse.position = (coords[0], coords[1]) def buy_xp() -> None: """Simulate pressing the 'f' key to purchase XP.""" keyboard.press('f') sleep(0.1) keyboard.release('f') sleep(0.1) def reroll() -> None: """Simulate pressing the 'd' key to purchase a reroll.""" keyboard.press('d') sleep(0.1) keyboard.release('d') sleep(0.1) def press_esc() -> None: """Simulate pressing the 'esc' key.""" keyboard.press(Key.esc) sleep(0.1) keyboard.release(Key.esc) sleep(0.1)