diff --git a/arena.py b/arena.py index 0b3c3ee..7282565 100644 --- a/arena.py +++ b/arena.py @@ -366,9 +366,11 @@ def spend_gold(self, speedy=False) -> None: # For set 11 encounter round shop delay and choose items popup for _ in range(15): + print("checking shop == blank") if speedy: return - if shop == [(1,""), (2,""), (3,""), (4,""), (5,"")]: + if all(champ[1] == "" for champ in shop): + print("shop == blank") sleep(1) anvil_msg: str = ocr.get_text( screenxy=screen_coords.ANVIL_MSG_POS.get_coords(), @@ -379,8 +381,12 @@ def spend_gold(self, speedy=False) -> None: if anvil_msg in ["ChooseOne", "Feelinglucky"]: print(" Choosing item") mk_functions.left_click(screen_coords.BUY_LOC[2].get_coords()) - sleep(1) + sleep(1.5) + shop: list = arena_functions.get_shop() break + shop: list = arena_functions.get_shop() + else: + break for champion in shop: if ( diff --git a/arena_functions.py b/arena_functions.py index 344fc03..37c7b11 100644 --- a/arena_functions.py +++ b/arena_functions.py @@ -100,7 +100,8 @@ def empty_slot() -> int: for slot, positions in enumerate(screen_coords.BENCH_HEALTH_POS): screen_capture = ImageGrab.grab(bbox=positions.get_coords()) screenshot_array = np.array(screen_capture) - if not (np.abs(screenshot_array - (0, 255, 18)) <= 3).all(axis=2).any(): + is_health_color = np.all(screenshot_array == [0, 255, 18], axis=-1) + if not any(np.convolve(is_health_color.reshape(-1), np.ones(5), mode='valid') >= 5): return slot # Slot 0-8 return -1 # No empty slot @@ -111,12 +112,22 @@ def bench_occupied_check() -> list: for positions in screen_coords.BENCH_HEALTH_POS: screen_capture = ImageGrab.grab(bbox=positions.get_coords()) screenshot_array = np.array(screen_capture) - if not (np.abs(screenshot_array - (0, 255, 18)) <= 2).all(axis=2).any(): - bench_occupied.append(False) - else: - bench_occupied.append(True) + is_health_color = np.all(screenshot_array == [0, 255, 18], axis=-1) + occupied = any(np.convolve(is_health_color.reshape(-1), np.ones(5), mode='valid') >= 5) + 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(np.abs(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/screen_coords.py b/screen_coords.py index 6c01f9d..66b26f3 100644 --- a/screen_coords.py +++ b/screen_coords.py @@ -8,15 +8,15 @@ from vec2 import Vec2 BENCH_HEALTH_POS: list[Vec4] = [ - Vec4(GameWindow(369, 622, 472, 757)), - Vec4(GameWindow(485, 622, 588, 757)), - Vec4(GameWindow(601, 622, 704, 757)), - Vec4(GameWindow(728, 622, 831, 757)), - Vec4(GameWindow(844, 622, 947, 757)), - Vec4(GameWindow(960, 622, 1063, 757)), - Vec4(GameWindow(1076, 622, 1179, 757)), - Vec4(GameWindow(1192, 622, 1295, 757)), - Vec4(GameWindow(1308, 622, 1411, 757)), + Vec4(GameWindow(369, 670, 472, 757)), + Vec4(GameWindow(485, 670, 588, 757)), + Vec4(GameWindow(601, 670, 704, 757)), + Vec4(GameWindow(728, 670, 831, 757)), + Vec4(GameWindow(844, 670, 947, 757)), + Vec4(GameWindow(960, 670, 1063, 757)), + Vec4(GameWindow(1076, 670, 1179, 757)), + Vec4(GameWindow(1192, 670, 1295, 757)), + Vec4(GameWindow(1308, 670, 1411, 757)), ] ITEM_POS: list[list] = [ @@ -56,6 +56,8 @@ ANVIL_MSG_POS: Vec4 = Vec4(GameWindow(818, 838, 932, 859)) +SELL_MSG_POS: Vec4 = Vec4(GameWindow(817, 1001, 828, 1001)) + EXIT_NOW_POS: Vec4 = Vec4(GameWindow(910, 560, 1029, 583)) AUGMENT_POS: list[Vec4] = [ @@ -81,7 +83,7 @@ ITEM_PICKUP_LOC: list[Vec2] = [ Vec2(1440, 611), Vec2(406, 544), - Vec2(1412, 486), + Vec2(1440, 486), Vec2(469, 440), Vec2(1380, 381), Vec2(644, 323),