-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathmana.py
28 lines (26 loc) · 835 Bytes
/
mana.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
from utils import global_utils
import os
import config
# Give a screenshot, returns the player mana
def get_mana(screenshot, screenshot_dimensions):
start = global_utils.start_timer()
remaining_mana = 0
mana = config.mana
mana = screenshot[
mana['y1']:
screenshot_dimensions[0] -
mana['y2'],
mana['x1']:
screenshot_dimensions[1] -
mana['x2']
]
for mana_haystack in os.listdir(config.mana_folder):
# Searching for a field in the folder.
searched_mana = global_utils.search(
config.mana_folder+"\\"+mana_haystack, mana, 1)
if searched_mana[0] == 1:
remaining_mana = int(mana_haystack[0])
end = global_utils.end_timer()
global_utils.log_time_elapsed(
"get_mana", end-start)
return remaining_mana