home · contact · privacy
Split LOGIN into NICK and LOGIN.
[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 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_NICK)
20 game.register_command(cmd_QUERY)
21 game.register_command(cmd_TURN)
22 game.register_command(cmd_MAP)
23 game.register_command(cmd_MAP_LINE)
24 game.register_command(cmd_GET_ANNOTATION)
25 game.register_command(cmd_ANNOTATE)
26 game.register_command(cmd_PORTAL)
27 game.register_command(cmd_GET_GAMESTATE)
28 game.register_task(Task_WAIT)
29 game.register_task(Task_MOVE)
30 game.register_task(Task_WRITE)
31 game.register_task(Task_FLATTEN_SURROUNDINGS)
32 game.read_savefile()
33 game.io.start_loop()
34 game.io.start_server(8000, PlomWebSocketServer)
35 game.io.start_server(5000, PlomTCPServer)