home · contact · privacy
Register game commands and tasks outside of game module.
[plomrogue2-experiments] / new2 / 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_QUERY, cmd_PING, cmd_MAP,
6                                 cmd_TURN, cmd_MAP_LINE, cmd_GET_ANNOTATION,
7                                 cmd_ANNOTATE, cmd_PORTAL, cmd_GET_GAMESTATE)
8 from plomrogue.tasks import (Task_WAIT, Task_MOVE, Task_WRITE,
9                              Task_FLATTEN_SURROUNDINGS)
10 import sys
11
12 if len(sys.argv) != 2:
13     print('wrong number of arguments, expected one (save file)')
14     exit(1)
15 savefile = sys.argv[1]
16 game = Game(savefile)
17 game.register_command(cmd_PING)
18 game.register_command(cmd_LOGIN)
19 game.register_command(cmd_QUERY)
20 game.register_command(cmd_TURN)
21 game.register_command(cmd_MAP)
22 game.register_command(cmd_MAP_LINE)
23 game.register_command(cmd_GET_ANNOTATION)
24 game.register_command(cmd_ANNOTATE)
25 game.register_command(cmd_PORTAL)
26 game.register_command(cmd_GET_GAMESTATE)
27 game.register_task(Task_WAIT)
28 game.register_task(Task_MOVE)
29 game.register_task(Task_WRITE)
30 game.register_task(Task_FLATTEN_SURROUNDINGS)
31 game.read_savefile()
32 game.io.start_loop()
33 game.io.start_server(8000, PlomWebSocketServer)
34 game.io.start_server(5000, PlomTCPServer)