-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gamestate.py
35 lines (33 loc) · 1.16 KB
/
gamestate.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
import information
from operator import attrgetter
class GameState:
def __init__(self, receive_time):
self.receive_time = receive_time
self.player = information.Player()
self.map = information.Map()
self.provider = information.Provider()
self.phase_countdowns = information.PhaseCountdowns()
self.bomb = information.Bomb()
self.round = information.Round()
def get(self, target, *argv):
try:
if len(argv) == 0:
state = attrgetter(f"{target}")(self)
elif len(argv) == 1:
state = attrgetter(f"{target}.{argv[0]}")(self)
elif len(argv) == 2:
obj = attrgetter(f"{target}.{argv[0]}")(self)
if hasattr(obj, "__getitem__"):
state = obj[f"{argv[1]}"]
else:
state = None
else:
print("Too many arguments.")
return False
if "object" in str(state):
return vars(state)
else:
return state
except Exception as E:
print(E)
return False