home · contact · privacy
d2e41177049c8ed6371e79b3d8ec75169796d430
[plomrogue2] / rogue_chat.py
1 #!/usr/bin/env python3
2 from plomrogue.game import Game
3 from plomrogue.io_websocket import PlomWebSocketServer
4 from plomrogue.io_tcp import PlomTCPServer
5 from plomrogue.commands import (cmd_ALL, cmd_LOGIN, cmd_NICK, cmd_QUERY, cmd_PING,
6                                 cmd_MAP, cmd_TURN, cmd_MAP_LINE, cmd_GET_ANNOTATION,
7                                 cmd_ANNOTATE, cmd_PORTAL, cmd_GET_GAMESTATE,
8                                 cmd_TASKS)
9 from plomrogue.tasks import (Task_WAIT, Task_MOVE, Task_WRITE,
10                              Task_FLATTEN_SURROUNDINGS)
11 import sys
12
13 if len(sys.argv) != 2:
14     print('wrong number of arguments, expected one (save file)')
15     exit(1)
16 savefile = sys.argv[1]
17 game = Game(savefile)
18 game.register_command(cmd_PING)
19 game.register_command(cmd_LOGIN)
20 game.register_command(cmd_NICK)
21 game.register_command(cmd_QUERY)
22 game.register_command(cmd_TURN)
23 game.register_command(cmd_MAP)
24 game.register_command(cmd_MAP_LINE)
25 game.register_command(cmd_GET_ANNOTATION)
26 game.register_command(cmd_ANNOTATE)
27 game.register_command(cmd_PORTAL)
28 game.register_command(cmd_GET_GAMESTATE)
29 game.register_command(cmd_TASKS)
30 game.register_task(Task_WAIT)
31 game.register_task(Task_MOVE)
32 game.register_task(Task_WRITE)
33 game.register_task(Task_FLATTEN_SURROUNDINGS)
34 game.read_savefile()
35 game.io.start_loop()
36 game.io.start_server(8000, PlomWebSocketServer)
37 game.io.start_server(5000, PlomTCPServer)