diff --git a/arena.py b/arena.py index 9843b39..108fe66 100644 --- a/arena.py +++ b/arena.py @@ -436,7 +436,7 @@ def pick_augment(self) -> None: screenxy=coords.get_coords(), scale=3, psm=7 ) augments.append(augment) - print(augments) + print(f" Augments: {augments}") if len(augments) == 3 and "" not in augments: break diff --git a/arena_functions.py b/arena_functions.py index 3dc3fbe..e7717d1 100644 --- a/arena_functions.py +++ b/arena_functions.py @@ -117,17 +117,6 @@ def bench_occupied_check() -> list: bench_occupied.append(occupied) return bench_occupied -# def board_occupied_check(known: bool, destination: tuple) -> bool: -# if known: -# mk_functions.left_click(destination.get_coords()) -# sleep(0.1) -# screen_capture = ImageGrab.grab(bbox=screen_coords.SELL_MSG_POS.get_coords()) -# mk_functions.left_click(destination.get_coords()) -# screenshot_array = np.array(screen_capture) -# if (np.sum(screenshot_array - (255, 247, 153) == 0).all(axis=2)) >= 5: -# return True -# else: -# return False def valid_item(item: str) -> str | None: """Checks if the item passed in arg one is valid""" diff --git a/game.py b/game.py index c65ef7b..f9f700f 100644 --- a/game.py +++ b/game.py @@ -22,7 +22,8 @@ class Game: def __init__(self, message_queue: multiprocessing.Queue) -> None: self.message_queue = message_queue self.arena = Arena(self.message_queue) - self.round = "0-0" + self.round: str = "0-0" + self.round_from: int = None self.time: None = None self.forfeit_time: int = settings.FORFEIT_TIME + random.randint(50, 150) self.found_window = False @@ -60,7 +61,7 @@ def callback(self, hwnd, extra) -> None: # pylint: disable=unused-argument def loading_screen(self) -> None: """Loop that runs while the game is in the loading screen""" game_functions.default_pos() - while game_functions.get_round() != "1-1": + while game_functions.get_round()[0] != "1-1": if self.check_failed_to_connect_window(): return sleep(1) @@ -71,9 +72,11 @@ def check_failed_to_connect_window(self) -> bool: """Check "Failed to Connect" windows and try to reconnect""" hwnd = win32gui.FindWindow(None, "Failed to Connect") if hwnd: - print(" Found \"Failed to Connect\" window, trying to exit and reconnect") + print(' Found "Failed to Connect" window, trying to exit and reconnect') if reconnect_button := win32gui.FindWindowEx(hwnd, 0, "Button", None): - if cancel_button := win32gui.FindWindowEx(hwnd, reconnect_button, "Button", None): + if cancel_button := win32gui.FindWindowEx( + hwnd, reconnect_button, "Button", None + ): print(" Exiting the game.") win32gui.SendMessage(cancel_button, BM_CLICK, 0, 0) return True @@ -82,7 +85,6 @@ def check_failed_to_connect_window(self) -> bool: print(" Reconnect button not found.") return False - def game_loop(self) -> None: """Loop that runs while the game is active, handles calling the correct tasks for round and exiting game""" ran_round: str = None @@ -105,7 +107,7 @@ def game_loop(self) -> None: break last_game_health = game_health - self.round: str = game_functions.get_round() + self.round, self.round_from = game_functions.get_round() if ( settings.FORFEIT @@ -203,10 +205,7 @@ def pvp_round(self) -> None: self.arena.bench_cleanup() if self.round in game_assets.ANVIL_ROUNDS: self.arena.clear_anvil() - if self.round in game_assets.PICKUP_ROUNDS: - self.arena.spend_gold(speedy=True) - else: - self.arena.spend_gold() + self.arena.spend_gold(speedy=self.round in game_assets.PICKUP_ROUNDS) self.arena.move_champions() self.arena.replace_unknown() if self.arena.final_comp: diff --git a/game_functions.py b/game_functions.py index d82448e..1c197d8 100644 --- a/game_functions.py +++ b/game_functions.py @@ -10,21 +10,21 @@ import mk_functions -def get_round() -> str: +def get_round() -> tuple[str, int]: """Gets the current game round""" screen_capture = ImageGrab.grab(bbox=screen_coords.ROUND_POS.get_coords()) round_three = screen_capture.crop(screen_coords.ROUND_POS_THREE.get_coords()) game_round: str = ocr.get_text_from_image(image=round_three, whitelist=ocr.ROUND_WHITELIST) if game_round in game_assets.ROUNDS: - return game_round + return game_round, 3 round_two = screen_capture.crop(screen_coords.ROUND_POS_TWO.get_coords()) game_round: str = ocr.get_text_from_image(image=round_two, whitelist=ocr.ROUND_WHITELIST) if game_round in game_assets.ROUNDS: - return game_round + return game_round, 2 round_one = screen_capture.crop(screen_coords.ROUND_POS_ONE.get_coords()) game_round: str = ocr.get_text_from_image(image=round_one, whitelist=ocr.ROUND_WHITELIST) - return game_round + return game_round, 1 def pickup_items() -> None: # Refacor this function to make it more clear whats happening @@ -43,7 +43,7 @@ def pickup_items() -> None: # Refacor this function to make it more clear whats def get_champ_carousel(tft_round: str) -> None: """Gets a champion from the carousel""" - while tft_round == get_round(): + while tft_round == get_round()[0]: mk_functions.right_click(screen_coords.CAROUSEL_LOC.get_coords()) sleep(0.7) sleep(3) diff --git a/screen_coords.py b/screen_coords.py index 6ff226f..7f7b851 100644 --- a/screen_coords.py +++ b/screen_coords.py @@ -135,7 +135,7 @@ Vec2(1251, 423), ] -CAROUSEL_LOC: Vec2 = Vec2(964, 644) +CAROUSEL_LOC: Vec2 = Vec2(964, 620) EXIT_NOW_LOC: Vec2 = Vec2(963, 575)