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