This repository has been archived by the owner on Aug 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimpleQueue.py
84 lines (73 loc) · 2.05 KB
/
simpleQueue.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
# Custom Queue class to track inputs for combos
class simpleQueue(object):
buttonMap = {
1: "Up",
2: "Down",
3: "Left",
4: "Right",
5: "Menu",
6: "View",
7: "L_Stick",
8: "R_Stick",
9: "L_Bumper",
10: "R_Bumper",
11: None,
12: None,
13: "A",
14: "B",
15: "X",
16: "Y",
None:None
}
def __init__(self, max, entities=[]):
self.max = max
self.list = entities
def __hash__(self):
result = 0
for elem in self.list:
result += elem
return hash(result)
def __eq__(self, other):
for i in range(len(self.list)):
if self.list[i] != other[i]:
return False
return True
def __str__(self):
if self.list == []:
return "[]"
else:
result = f"[{simpleQueue.buttonMap[self.list[0]]}"
for elem in self.list[1:]:
result += ", " + str(simpleQueue.buttonMap[elem])
result += "]"
return result
def __iter__(self):
for elem in self.list:
yield elem
def __repr__(self):
return f"simpleQueue({self.max}, {self.list})"
def pop(self):
return simpleQueue(self.max, self.list[1:])
def popFirst(self):
result = self.list[0]
self.list = self.pop
return result
def join(self, elem):
if len(self.list) < self.max:
self.list.append(elem)
else:
temp = self.pop()
temp.join(elem)
self.list = temp.list
def getLastElement(self):
if self.list != []:
return self.list[-1]
def clear(self):
self.list = []
def findCombos(self, combo):
if len(self.list) < 2:
return None
elif self.list == combo:
return self.list
else:
return self.pop().findCombos(combo)