home · contact · privacy
Improve help system.
[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, cmd_MAP_CONTROL_LINE, cmd_MAP_CONTROL_PW)
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_MAP_CONTROL_LINE)
26 game.register_command(cmd_MAP_CONTROL_PW)
27 game.register_command(cmd_GET_ANNOTATION)
28 game.register_command(cmd_ANNOTATE)
29 game.register_command(cmd_PORTAL)
30 game.register_command(cmd_GET_GAMESTATE)
31 game.register_command(cmd_TASKS)
32 game.register_task(Task_WAIT)
33 game.register_task(Task_MOVE)
34 game.register_task(Task_WRITE)
35 game.register_task(Task_FLATTEN_SURROUNDINGS)
36 game.read_savefile()
37 game.io.start_loop()
38 game.io.start_server(8000, PlomWebSocketServer)
39 game.io.start_server(5000, PlomTCPServer)