Skip to content

Commit 3a19692

Browse files
authored
Update for set11 encounter add one round
Not tested yet
1 parent 7a590de commit 3a19692

File tree

4 files changed

+117
-23
lines changed

4 files changed

+117
-23
lines changed

game.py

Lines changed: 70 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Game:
2222
def __init__(self, message_queue: multiprocessing.Queue) -> None:
2323
self.message_queue = message_queue
2424
self.arena = Arena(self.message_queue)
25-
self.round: str = "0-0"
25+
self.round: list[str, int] = ["0-0", 0]
2626
self.time: None = None
2727
self.forfeit_time: int = settings.FORFEIT_TIME + random.randint(50, 150)
2828
self.found_window = False
@@ -60,7 +60,7 @@ def callback(self, hwnd, extra) -> None: # pylint: disable=unused-argument
6060
def loading_screen(self) -> None:
6161
"""Loop that runs while the game is in the loading screen"""
6262
game_functions.default_pos()
63-
while game_functions.get_round() != "1-1":
63+
while game_functions.get_round()[0] != "1-1":
6464
if self.check_failed_to_connect_window():
6565
return
6666
sleep(1)
@@ -115,21 +115,80 @@ def game_loop(self) -> None:
115115
game_functions.forfeit()
116116
return
117117

118-
if self.round != ran_round:
119-
if self.round in game_assets.PVP_ROUND:
118+
if self.round[0] != ran_round:
119+
if self.round[0] in game_assets.PVP_ROUND:
120120
game_functions.default_pos()
121121
self.pvp_round()
122-
ran_round: str = self.round
123-
elif self.round in game_assets.PVE_ROUND:
122+
ran_round: str = self.round[0]
123+
elif self.round[0] in game_assets.PVE_ROUND:
124124
game_functions.default_pos()
125125
self.pve_round()
126-
ran_round: str = self.round
127-
elif self.round in game_assets.CAROUSEL_ROUND:
126+
ran_round: str = self.round[0]
127+
elif self.round[0] in game_assets.CAROUSEL_ROUND:
128128
self.carousel_round()
129-
ran_round: str = self.round
130-
elif self.round in game_assets.SECOND_ROUND:
129+
ran_round: str = self.round[0]
130+
elif self.round[0] in game_assets.SECOND_ROUND:
131131
self.second_round()
132-
ran_round: str = self.round
132+
ran_round: str = self.round[0]
133+
elif self.round[0] in game_assets.ENCOUNTER_ROUNDS:
134+
print(f"\n[Encounter Round] {self.round}")
135+
print(" Do nothing")
136+
self.message_queue.put("CLEAR")
137+
self.arena.check_health()
138+
ran_round: str = self.round[0]
139+
if self.round[1] == 1 and self.round[0].split("-")[1] == "1":
140+
game_assets.CAROUSEL_ROUND = {
141+
carousel_round
142+
for carousel_round in game_assets.CAROUSEL_ROUND
143+
if not carousel_round.startswith(self.round[0].split("-"))
144+
}
145+
game_assets.PVE_ROUND = {
146+
pve_round
147+
for pve_round in game_assets.PVE_ROUND
148+
if not pve_round.startswith(self.round[0].split("-"))
149+
}
150+
game_assets.PVP_ROUND = {
151+
pvp_round
152+
for pvp_round in game_assets.PVP_ROUND
153+
if not pvp_round.startswith(self.round[0].split("-"))
154+
}
155+
game_assets.ANVIL_ROUNDS = {
156+
anvil_round
157+
for anvil_round in game_assets.ANVIL_ROUNDS
158+
if not anvil_round.startswith(self.round[0].split("-"))
159+
}
160+
game_assets.ITEM_PLACEMENT_ROUNDS = {
161+
item_placement_round
162+
for item_placement_round in game_assets.ITEM_PLACEMENT_ROUNDS
163+
if not item_placement_round.startswith(self.round[0].split("-"))
164+
}
165+
for index, round_msg in enumerate(
166+
game_functions.check_encounter_round()
167+
):
168+
if index == 0:
169+
continue
170+
if round_msg == "carousel":
171+
game_assets.CAROUSEL_ROUND.add(
172+
self.round[0].split("-") + "-" + str(index + 1)
173+
)
174+
game_assets.ANVIL_ROUNDS.add(
175+
self.round[0].split("-") + "-" + str(index + 2)
176+
)
177+
game_assets.ITEM_PLACEMENT_ROUNDS.add(
178+
self.round[0].split("-") + "-" + str(index + 2)
179+
)
180+
elif round_msg == "pve":
181+
game_assets.PVE_ROUND.add(
182+
self.round[0].split("-") + "-" + str(index + 1)
183+
)
184+
elif round_msg == "pvp":
185+
game_assets.PVP_ROUND.add(
186+
self.round[0].split("-") + "-" + str(index + 1)
187+
)
188+
elif round_msg == "encounter":
189+
game_assets.ENCOUNTER_ROUNDS.add(
190+
self.round[0].split("-") + "-" + str(index + 1)
191+
)
133192
sleep(0.5)
134193

135194
def second_round(self) -> None:

game_assets.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@
104104

105105

106106
ROUNDS: set[str] = {"1-1", "1-2", "1-3", "1-4",
107-
"2-1", "2-2", "2-3", "2-4", "2-5", "2-6", "2-7",
108-
"3-1", "3-2", "3-3", "3-4", "3-5", "3-6", "3-7",
109-
"4-1", "4-2", "4-3", "4-4", "4-5", "4-6", "4-7",
110-
"5-1", "5-2", "5-3", "5-4", "5-5", "5-6", "5-7",
111-
"6-1", "6-2", "6-3", "6-4", "6-5", "6-6", "6-7",
112-
"7-1", "7-2", "7-3", "7-4", "7-5", "7-6", "7-7"}
107+
"2-1", "2-2", "2-3", "2-4", "2-5", "2-6", "2-7", "2-8",
108+
"3-1", "3-2", "3-3", "3-4", "3-5", "3-6", "3-7", "3-8",
109+
"4-1", "4-2", "4-3", "4-4", "4-5", "4-6", "4-7", "4-8",
110+
"5-1", "5-2", "5-3", "5-4", "5-5", "5-6", "5-7", "5-8",
111+
"6-1", "6-2", "6-3", "6-4", "6-5", "6-6", "6-7", "6-8",
112+
"7-1", "7-2", "7-3", "7-4", "7-5", "7-6", "7-7", "7-8"}
113113

114114
SECOND_ROUND: set[str] = {"1-2"}
115115

@@ -132,6 +132,7 @@
132132

133133
ITEM_PLACEMENT_ROUNDS: set[str] = {"2-2", "3-2", "4-2", "5-2",
134134
"6-2", "7-2", "2-5", "3-5", "4-5", "5-5", "6-5", "7-5"}
135+
ENCOUNTER_ROUNDS: set[str] = {"0-0"}
135136

136137
FINAL_COMP_ROUND = "4-5"
137138

game_functions.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,45 @@
1010
import mk_functions
1111

1212

13-
def get_round() -> str:
13+
def get_round() -> list[str, int]:
1414
"""Gets the current game round"""
1515
screen_capture = ImageGrab.grab(bbox=screen_coords.ROUND_POS.get_coords())
1616
round_three = screen_capture.crop(screen_coords.ROUND_POS_THREE.get_coords())
1717
game_round: str = ocr.get_text_from_image(image=round_three, whitelist=ocr.ROUND_WHITELIST)
1818
if game_round in game_assets.ROUNDS:
19-
return game_round
19+
return [game_round, 3]
2020

2121
round_two = screen_capture.crop(screen_coords.ROUND_POS_TWO.get_coords())
2222
game_round: str = ocr.get_text_from_image(image=round_two, whitelist=ocr.ROUND_WHITELIST)
2323
if game_round in game_assets.ROUNDS:
24-
return game_round
24+
return [game_round, 2]
25+
2526
round_one = screen_capture.crop(screen_coords.ROUND_POS_ONE.get_coords())
2627
game_round: str = ocr.get_text_from_image(image=round_one, whitelist=ocr.ROUND_WHITELIST)
27-
return game_round
28-
28+
return [game_round, 1]
29+
30+
31+
def check_encounter_round() -> list[str]:
32+
"""Get the game round list by checking round text for encounter add rounds"""
33+
round_list: list = []
34+
for positions in screen_coords.ROUND_ENCOUNTER_ICON_POS:
35+
mk_functions.move_mouse(positions[0].get_coords())
36+
round_message: str = ocr.get_text(
37+
screenxy=positions[1].get_coords(),
38+
scale=3,
39+
psm=7,
40+
whitelist=ocr.ALPHABET_WHITELIST,
41+
)
42+
if any(keyword in round_message for keyword in ["Carousel"]):
43+
round_list.append("carousel")
44+
elif any(keyword in round_message for keyword in ["Get pulled into an Encounter"]):
45+
round_list.append("encounter")
46+
elif any(keyword in round_message for keyword in ["Krugs", "Murk Wolves", "Raptors"]):
47+
round_list.append("pve")
48+
else:
49+
round_list.append("pvp")
50+
mk_functions.move_mouse(screen_coords.DEFAULT_LOC.get_coords())
51+
return round_list
2952

3053
def pickup_items() -> None: # Refacor this function to make it more clear whats happening
3154
"""Picks up items from the board after PVP round"""
@@ -43,7 +66,7 @@ def pickup_items() -> None: # Refacor this function to make it more clear whats
4366

4467
def get_champ_carousel(tft_round: str) -> None:
4568
"""Gets a champion from the carousel"""
46-
while tft_round == get_round():
69+
while tft_round == get_round()[0]:
4770
mk_functions.right_click(screen_coords.CAROUSEL_LOC.get_coords())
4871
sleep(0.7)
4972
sleep(3)

screen_coords.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@
4040

4141
ROUND_POS_THREE: Vec4 = Vec4(GameWindow(71, 0, 110, 24), use_screen_offset=False)
4242

43+
ROUND_ENCOUNTER_ICON_POS: list[list[Vec2, Vec4]] = [
44+
[Vec2(833, 20), Vec4(GameWindow(926, 49, 1191, 75))],
45+
[Vec2(869, 20), Vec4(GameWindow(962, 49, 1227, 75))],
46+
[Vec2(905, 20), Vec4(GameWindow(998, 49, 1263, 75))],
47+
[Vec2(941, 20), Vec4(GameWindow(1034, 49, 1299, 75))],
48+
[Vec2(977, 20), Vec4(GameWindow(1070, 49, 1335, 75))],
49+
[Vec2(1013, 20), Vec4(GameWindow(1106, 49, 1371, 75))],
50+
[Vec2(1049, 20), Vec4(GameWindow(1142, 49, 1407, 75))],
51+
[Vec2(1085, 20), Vec4(GameWindow(1178, 49, 1443, 75))],
52+
]
53+
4354
SHOP_POS: Vec4 = Vec4(GameWindow(481, 1039, 1476, 1070))
4455

4556
CHAMP_NAME_POS: list[Vec4] = [

0 commit comments

Comments
 (0)