-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer_manager.py
45 lines (33 loc) · 923 Bytes
/
player_manager.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
#!/bin/python3
'''
Handle communication with players
'''
import json
from games.goofspiel import Goofspiel
from games.hearts import Hearts
def container_cb(player, info):
json.dumps(info)
try:
json.loads()
except json.JSONDecodeError:
print("Not valid JSON ... tut tut!")
def player_cb(player, info):
print("Player: " + str(player))
print("Information: " + str(info))
return input("What card are you playing? ")
def main():
game_str = input("What game do you want to play?").lower()
if game_str == "goofspiel":
game = Goofspiel(player_cb)
elif game_str == "hearts":
game = Hearts(player_cb)
else:
print("Here is a list of the current games:")
print("goofspiel")
print("hearts")
return False
game.play()
return True
if __name__ == "__main__":
while main():
print("\nLet's try again... ")