home · contact · privacy
e15ee242e92d71e9c9e3a637e7e989f65f75ac13
[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_PING, cmd_THING,
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                                 cmd_GOD_ANNOTATE, cmd_GOD_PORTAL, cmd_THING_TYPES)
10 from plomrogue.tasks import (Task_WAIT, Task_MOVE, Task_WRITE, Task_PICK_UP,
11                              Task_DROP, Task_FLATTEN_SURROUNDINGS)
12 from plomrogue.things import Thing_Player, Thing_Stone
13 import sys
14
15 if len(sys.argv) != 2:
16     print('wrong number of arguments, expected one (save file)')
17     exit(1)
18 savefile = sys.argv[1]
19 game = Game(savefile)
20 game.register_command(cmd_PING)
21 game.register_command(cmd_ALL)
22 game.register_command(cmd_LOGIN)
23 game.register_command(cmd_NICK)
24 game.register_command(cmd_TURN)
25 game.register_command(cmd_MAP)
26 game.register_command(cmd_MAP_LINE)
27 game.register_command(cmd_MAP_CONTROL_LINE)
28 game.register_command(cmd_MAP_CONTROL_PW)
29 game.register_command(cmd_GET_ANNOTATION)
30 game.register_command(cmd_ANNOTATE)
31 game.register_command(cmd_PORTAL)
32 game.register_command(cmd_GOD_ANNOTATE)
33 game.register_command(cmd_GOD_PORTAL)
34 game.register_command(cmd_GET_GAMESTATE)
35 game.register_command(cmd_TASKS)
36 game.register_command(cmd_THING_TYPES)
37 game.register_command(cmd_THING)
38 game.register_task(Task_WAIT)
39 game.register_task(Task_MOVE)
40 game.register_task(Task_WRITE)
41 game.register_task(Task_FLATTEN_SURROUNDINGS)
42 game.register_task(Task_PICK_UP)
43 game.register_task(Task_DROP)
44 game.register_thing_type(Thing_Player)
45 game.register_thing_type(Thing_Stone)
46 game.read_savefile()
47 game.io.start_loop()
48 game.io.start_server(8000, PlomWebSocketServer)
49 game.io.start_server(5000, PlomTCPServer)