forked from jfd02/TFT-OCR-BOT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_functions.py
73 lines (58 loc) · 2.06 KB
/
game_functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from time import sleep
from PIL import ImageGrab
import screen_coords
import ocr
import game_assets
import mk_functions
def get_round() -> str:
screen_capture = ImageGrab.grab(bbox=screen_coords.round_pos)
round_two_x = screen_capture.crop(screen_coords.round_pos_two)
game_round = ocr.get_text_image(image=round_two_x, whitelist="0123456789-")
if game_round in game_assets.rounds:
return game_round
else:
round_one_x = screen_capture.crop(screen_coords.round_pos_one)
game_round = ocr.get_text_image(image=round_one_x, whitelist="0123456789-")
return game_round
# def pickup_items():
# for index, coords in enumerate(screen_coords.item_pickup_loc):
# mk_functions.right_click(coords)
# if index == 7: # Don't need to sleep on final click
# return
# if index == 0:
# sleep(1.2)
# if index % 2 == 0:
# sleep(2)
# else:
# sleep(1.2)
def get_champ_carousel(tft_round):
mk_functions.right_click(screen_coords.carousel_loc)
if tft_round == '1-1':
sleep(9.5)
mk_functions.right_click(screen_coords.carousel_loc)
elif tft_round == '2-4':
sleep(5)
for _ in range(6):
sleep(3)
mk_functions.right_click(screen_coords.carousel_loc)
else:
for _ in range(6):
sleep(3)
mk_functions.right_click(screen_coords.carousel_loc)
def check_alive() -> bool:
if ocr.get_text(screenxy=screen_coords.exit_now_pos, scale=3, psm=7, whitelist='') == 'EXIT NOW':
return False
elif ocr.get_text(screenxy=screen_coords.victory_pos, scale=3, psm=7, whitelist='') == 'CONTINUE':
return False
else:
return True
def exit_game():
mk_functions.left_click(screen_coords.exit_now_loc)
def default_pos():
mk_functions.left_click(screen_coords.default_loc)
def forfeit():
mk_functions.press_esc()
mk_functions.left_click(screen_coords.surrender_loc)
sleep(0.1)
mk_functions.left_click(screen_coords.surrender2_loc)
sleep(1)