-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutputmanager.py
128 lines (82 loc) · 2.3 KB
/
outputmanager.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
import time
import pyautogui
class OutputManager():
def __init__(self):
pass
def getReadyForInput(self):
pass
def rotate(self):
pass
def moveToMaxLeft(self):
pass
def moveRight(self):
pass
def throwDown(self):
pass
def output(self, rotation, position):
# rotate piece
# move piece to max left by long swipe
# Move piece step by step to right position
# Send piece down
# Reset
self.getReadyForInput()
for r in range(rotation):
self.rotate()
self.moveToMaxLeft()
for p in range(position):
self.moveRight()
self.throwDown()
class PrintOutputManager(OutputManager):
def __init__(self):
super().__init__()
def getReadyForInput(self):
pass
def rotate(self):
print("Outpt: Rotate")
def moveToMaxLeft(self):
print("Output: Move to max left")
def moveRight(self):
print("Output: Move right")
def throwDown(self):
print("Output: Throw down")
class IngoAppOutputManager(OutputManager):
def __init__(self):
super().__init__()
def getReadyForInput(self):
pass
def rotate(self):
assert False, "Not implemented"
def moveToMaxLeft(self):
assert False, "Not implemented"
def moveRight(self):
assert False, "Not implemented"
def throwDown(self):
assert False, "Not implemented"
class LumptyOutputManager(OutputManager):
def __init__(self):
super().__init__()
def getReadyForInput(self):
time.sleep(0.7)
def rotate(self):
pyautogui.press('up')
def moveToMaxLeft(self):
pyautogui.press('left', presses=4)
def moveRight(self):
pyautogui.press('right')
def throwDown(self):
pyautogui.keyDown('down')
time.sleep(0.06)
pyautogui.keyUp('down')
class JstrisOutputManager(OutputManager):
def __init__(self):
super().__init__()
def getReadyForInput(self):
pass
def rotate(self):
pyautogui.press('up')
def moveToMaxLeft(self):
pyautogui.press('left', presses=5)
def moveRight(self):
pyautogui.press('right')
def throwDown(self):
pyautogui.press('space')