-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
148 lines (122 loc) · 3.81 KB
/
main.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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import settings
from agent import Agent
import keyboard
import time
import os
import pywinauto
from pynput import keyboard
import threading
from PIL import Image
import sys
import pyautogui
pyautogui.FAILSAFE = False
agents = []
run = 0
def generateAgents():
agent_number = int(os.getenv('AGENT_NUMBER'))
medivia_path = os.getenv('MEDIVIA_PATH')
i = 1
while i <= agent_number:
app = pywinauto.Application().start(r'{}'.format(medivia_path))
print(app.process)
agents.append(Agent(i, app))
i += 1
def hasAgentRunning():
global run
for agent in agents:
if agent.state == Agent.RUNNING:
return True
if len(agents) == 0:
run = 0
return False
def pause():
print('Vou dar uma pausadinha amigão')
global run
run = 0
def die(icon = None):
pyautogui.alert('Adeus, até a proxima', 'Tchau')
print('Adeus amigão, espero que eu tenha lhe ajudado')
global run
run = 0
change_state.stop()
#For icon tray
if icon:
icon.visible = False
icon.stop()
sys.exit()
def isValidItems():
for agent in agents:
if not agent.isValidItems():
print('Configuração de imagens / itens errados ['+str(agent.char_name)+']')
return False
return True
def start():
global run
print('Vamos la!')
run = 1
threading.Thread(target = init).start()
def init():
global run
lock = threading.Lock()
while run:
total_mana_spent = 0
total_rune_made = 0
changed = False
with lock:
for agent in agents:
if not hasAgentRunning() and agent.canSpell():
print('Agent '+agent.char_name+' preparado para fazer')
agent.run()
changed = True
total_mana_spent += agent.total_mana_spent
total_rune_made += agent.total_rune_made
if agent.state == Agent.FINISHED:
print('Agent '+agent.char_name+' removido: quantidade de runas concluidas ou acabou a food')
agents.remove(agent)
if changed:
print('Total de runas feitas: '+str(total_rune_made))
print('Total de mana gasta: '+str(total_mana_spent))
time.sleep(1)
def reboot():
generateAgents()
start()
def startDraw():
threading.Thread(target = draw).start()
def draw():
global run
run = not run
time.sleep(5)
pyautogui.click()
distance = 50
lock = threading.Lock()
initialPosition = pyautogui.position()
while distance > 0 and run:
with lock:
pyautogui.dragRel(distance, 0)
distance = distance - 5 # ❹
pyautogui.dragRel(0, distance, duration=0.0)
pyautogui.dragRel(-distance, 0, duration=0.1)
distance = distance - 5
pyautogui.dragRel(0, -distance, duration=0.2)
if run:
pyautogui.dragTo(initialPosition)
time.sleep(5)
pyautogui.dragTo(initialPosition, duration=0.1)
time.sleep(5)
pyautogui.dragTo(initialPosition, duration=0.2)
time.sleep(5)
pyautogui.dragTo(initialPosition, button='left', duration=0.2)
time.sleep(5)
pyautogui.dragTo(initialPosition, button='left', duration=1)
pyautogui.moveTo(initialPosition)
pyautogui.mouseDown(button='left')
pyautogui.move(0, 30)
pyautogui.mouseUp(button='left')
if __name__ == "__main__":
generateAgents()
with keyboard.GlobalHotKeys({
'<ctrl>+<alt>+s': start,
'<ctrl>+<alt>+p': pause,
'<ctrl>+<alt>+q': die,
'<ctrl>+<alt>+t': startDraw}) as change_state:
change_state.join()