-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
131 lines (107 loc) · 4.46 KB
/
main.py
File metadata and controls
131 lines (107 loc) · 4.46 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import csv
import json
import dxcam
import requests
from threading import Thread
from datetime import datetime, timedelta
from pynput import keyboard, mouse
from functions import get_active_player_name, get_player_champion, is_game_live, parse_time, format_time
from urls import lol_live_game_stats_url
from overlay import Overlay
from trayicon import TrayIcon
from camera import get_player_cs, region
if __name__ == '__main__':
csv_url = 'https://raw.githubusercontent.com/j4n7/zilean/develop/clears.csv'
with requests.get(csv_url, stream=True) as response:
lines = (line.decode('utf-8') for line in response.iter_lines())
reader = csv.reader(lines)
clears = {(row[2], row[3]): row[6:] for row in reader}
del clears[('champion', 'start')]
for clear, times in clears.items():
clears[clear] = [parse_time(time) for time in times]
overlay = Overlay()
camera = dxcam.create(output_color='RGBA')
class Start:
def __init__(self):
self.color = 'blue'
start = Start()
start_time = None
count_time = True
camp_info = ''
def input_thread():
def on_press(key):
global start_time
global count_time
global camp_info
keys = ['q', 'w', 'e', 'r', 'd', 'f']
try:
if str(key) == 'Key.backspace':
count_time = not count_time
camp_info = ''
elif key.char in keys:
if not count_time:
start_time = datetime.now() - timedelta(seconds=90)
count_time = True
except AttributeError:
'''Special keys such as Backspace'''
def on_click(x, y, button, pressed):
global start_time
global count_time
if pressed:
if not count_time:
start_time = datetime.now() - timedelta(seconds=90)
count_time = True
listener_keyboard = keyboard.Listener(
on_press=on_press)
listener_keyboard.start()
listener_mouse = mouse.Listener(
on_click=on_click)
listener_mouse.start()
def message_thread():
global start_time
global count_time
global camp_info
global camera
while True:
if is_game_live() and not start_time:
response = requests.get(lol_live_game_stats_url, verify=False)
game_time = timedelta(seconds=json.loads(response.text)['gameTime'])
start_time = datetime.now() + timedelta(seconds=1) - game_time
# print(start_time)
champion = get_player_champion(get_active_player_name()).lower()
overlay.deiconify()
elif is_game_live() and start_time:
clear = clears[(champion, start.color)] if (champion, start.color) in clears else None
if count_time:
current_time = format_time(datetime.now() - start_time)
cs = get_player_cs(camera, region)
if cs != 777:
n = 0
while cs - 4 >= 0:
cs -= 4
n += 1
if clear and n < 6:
if clear[n] > datetime.now() - start_time:
time_left = '-' + format_time(clear[n] - (datetime.now() - start_time))
else:
time_left = '+' + format_time((datetime.now() - start_time) - clear[n])
camp_info = f'\nCamp {n + 1}\n{format_time(clear[n])}\n{time_left}'
else:
camp_info = ''
current_time += camp_info
overlay.set_message(current_time)
else:
overlay.set_message('Waiting for input...')
else:
start_time = None
# overlay.set_message('Waiting for game...')
overlay.withdraw()
# print('Waiting for game...', end='\r')
tray_thread = Thread(target=lambda: TrayIcon(overlay, start))
tray_thread.start()
thread = Thread(target=message_thread)
thread.start()
key_thread = Thread(target=input_thread)
key_thread.start()
overlay.set_message('Zilean\nSTARTING\nIt will minimize to system tray')
overlay.run()