-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_cli_menu.py
50 lines (41 loc) · 1.32 KB
/
main_cli_menu.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
from src.Game import Game
from src.Models import User, Match, MatchRequest
from src.SocketClient import SocketClient
from pygame.display import set_caption as set_pygame_window_title
def multiplayer_game():
username = input("type your username:\n")
me = User(username=username)
socket = SocketClient()
socket.register_user(user=me)
game = Game(is_multiplayer=True, socket_client=socket)
ans = input("are you want to make game request? [y/n] ")
if ans == "y":
socket.make_match_request()
elif ans == "n":
exit()
else:
raise Exception("Invalid command")
print("Finding your opponent...")
match = socket.pend_for_match_start()
game.left_side_name = match.left_user.username
game.right_side_name = match.right_user.username
game.pygame_init()
game.load_assets()
game.board.init_objects()
set_pygame_window_title(username)
game.run()
def monoplayer_game():
game = Game()
game.pygame_init()
game.load_assets()
game.board.init_objects()
game.run()
if __name__ == '__main__':
game_type = input("1) Monoplayer(Offline)\n2) Multiplayer(Online)\n:")
match game_type:
case "1":
monoplayer_game()
case "2":
multiplayer_game()
case _:
raise Exception("Invalid game type.")