-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkonami.py
executable file
·51 lines (39 loc) · 1.51 KB
/
konami.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
from src.sequences import Sequences
import random
# Up, Up, Down, Down, Left, Right, Left, Right, B, A, Start
KONAMI_CODE = ('up', 'up', 'down', 'down', 'left', 'right', 'left', 'right', 'b', 'a', 'start')
CODE_NAME = 'konami'
COMBO_CODE = ('left', 'right', 'b', 'a')
def main():
sq = Sequences()
## Install the konami
sq.input_sequence(KONAMI_CODE, CODE_NAME)
## Add other button presses
sq.input_sequence(COMBO_CODE, 'COMBO!')
sq.input_sequence(COMBO_CODE+COMBO_CODE, 'DOUBLE COMBO!')
run_konami_test(sq)
return sq
from time import sleep
def run_konami_test(sq):
"""Run the tool, simulating button input presses
"""
button_sequence = KONAMI_CODE[2:-5] + COMBO_CODE[:-1] + COMBO_CODE[2:-1] + KONAMI_CODE[:-1]
for button in button_sequence:
# Use _table_ insert_keys, for convenience.
print(f'\n ----> ', button)
hots, matches, drops = sq.table_insert_keys([button])
# (('konami',), (), ())
print('')
# print(' Activated', hots)
print(' Complete ', matches)
print(' Dropped ', drops)
t = random.randrange(0,4) * .1
sleep(.3 + t)
# Upon hitting the start button, the konami code activayess,
# pushing from _started_ to _complete_.
hots, matches, drops = sq.table_insert_keys(['start'])
# ((), ('konami',), ())
print('\nComplete', matches)
assert CODE_NAME in matches, 'Konami did not activate!'
if __name__ == '__main__':
sq = main()