Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony5301 authored Apr 5, 2024
1 parent c33fbc6 commit fa12fe0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 28 deletions.
2 changes: 1 addition & 1 deletion arena.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 0 additions & 11 deletions arena_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
19 changes: 9 additions & 10 deletions game.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
10 changes: 5 additions & 5 deletions game_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion screen_coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit fa12fe0

Please sign in to comment.