-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkonami_demo.py
28 lines (21 loc) · 939 Bytes
/
konami_demo.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
from src.sequences import Sequences
# Define the Konami Code sequence
KONAMI_CODE = ('up', 'up', 'down', 'down',
'left', 'right',
'left', 'right',
'b', 'a', 'start'
)
CODE_NAME = 'konami'
# Initialize the Sequences object
sq = Sequences()
# Input the Konami Code sequence into the Sequences object
sq.input_sequence(KONAMI_CODE, CODE_NAME)
# Simulate button presses and check for matches
button_sequence = KONAMI_CODE[:-1] # Simulate pressing all buttons except the last one
hots, matches, drops = sq.table_insert_keys(button_sequence)
# At this point, no complete matches are found
print("Complete", matches) # Output: Complete ()
# Press the last button in the sequence
hots, matches, drops = sq.table_insert_keys(['start'])
# Now, the Konami Code sequence is successfully matched
print("Complete", matches) # Output: Complete ('konami',)