-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
100 lines (85 loc) · 3.06 KB
/
bot.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
from enum import Enum
from sys import flags
from pynput.mouse import Button, Controller
from pynput.keyboard import Key
from flags import Flags
from task import Task
class BotStates(Enum):
INIT = 1
START = 2
GET_ALT_ORB_POSITION = 3
GET_AUG_ORB_POSITION = 4
GET_ITEM_POSITION = 5
WORKING = 6
class Bot:
flags = Flags()
task = Task()
shutdown = False
block_state_change = False
state = BotStates.INIT
mouse = Controller()
alt_pos = None
aug_pos = None
item_pos = None
def next_command(self):
if self.shutdown:
return
if self.block_state_change:
return
if self.state == BotStates.INIT:
print("press \"ctrl + alt + l\" to start", end="\r")
if self.state == BotStates.START:
print("position the mouse on ALTERATION ORB: press ctrl+alt+j", end="\r")
if self.state == BotStates.GET_ALT_ORB_POSITION:
print("position the mouse on AUGMENTATION ORB: press ctrl+alt+j", end="\r")
if self.state == BotStates.GET_AUG_ORB_POSITION:
print("position the mouse on ITEM: press ctrl+alt+j", end="\r")
if self.state == BotStates.GET_ITEM_POSITION:
print("press \"ctrl + alt + j\" to BEGIN THE WORK", end="\r")
if self.state == BotStates.WORKING:
print("alt_pos", self.alt_pos, "aug_pos", self.aug_pos, "item_pos", self.item_pos, end="\r")
self.task.tick(self.mouse, self.alt_pos, self.aug_pos, self.item_pos)
def set_next_state(self):
# print(self.state)
if self.block_state_change:
return
if self.state == BotStates.START:
self.set_state_to_alt_orb_position()
elif self.state == BotStates.GET_ALT_ORB_POSITION:
self.set_state_to_aug_orb_position()
elif self.state == BotStates.GET_AUG_ORB_POSITION:
self.set_state_to_item_position()
elif self.state == BotStates.GET_ITEM_POSITION:
self.set_state_to_working()
def set_state_to_alt_orb_position(self):
self.alt_pos = self.mouse.position
self.state = BotStates.GET_ALT_ORB_POSITION
def set_state_to_aug_orb_position(self):
self.aug_pos = self.mouse.position
self.state = BotStates.GET_AUG_ORB_POSITION
def set_state_to_item_position(self):
self.item_pos = self.mouse.position
self.state = BotStates.GET_ITEM_POSITION
def set_state_to_working(self):
self.state = BotStates.WORKING
def start_bot(self):
if self.block_state_change:
return
if self.state == BotStates.INIT:
self.state = BotStates.START
def receive_key_press(self, key):
self.flags.check_received_ctrl_press(key)
self.flags.check_received_alt_press(key)
if '{0}'.format(key) == "<74>":
self.set_next_state()
self.block_state_change = True
# print("cctrl-alt-o", '\n')
if '{0}'.format(key) == "<76>":
self.start_bot()
self.block_state_change = True
# print("cctrl-alt-p", '\n')
def receive_key_release(self, key):
self.flags.check_received_ctrl_release(key)
self.flags.check_received_alt_release(key)
if not self.flags.is_alt_pressed and not self.flags.is_ctrl_pressed:
self.block_state_change = False