--- /dev/null
+from plomrogue.io_websocket import PlomWebSocketServer
+from plomrogue.io_tcp import PlomTCPServer, PlomTCPServerSSL
+from plomrogue.errors import ArgError
+
+def parse_command_line_arguments():
+ import argparse
+ parser = argparse.ArgumentParser()
+ parser.add_argument('savefile')
+ parser.add_argument('--server-type', nargs='+', required=True,
+ choices=['tcp', 'tcp_ssl', 'ws'])
+ parser.add_argument('--port', nargs='+', required=True, type=int)
+ parser.add_argument('--keyfile')
+ parser.add_argument('--certfile')
+ opts = parser.parse_args()
+ if len(opts.server_type) != len(opts.port):
+ raise ArgError('number of ports unequal to number of server types')
+ if 'tcp_ssl' in opts.server_type and not (opts.keyfile or opts.certfile):
+ raise ArgError('need key and cert file for tcp_ssl server')
+ config = {
+ 'savefile': opts.savefile,
+ 'servers': {},
+ 'keyfile': opts.keyfile,
+ 'certfile': opts.certfile,
+ }
+ for i in range(len(opts.port)):
+ server_type = opts.server_type[i]
+ if server_type == 'ws':
+ config['servers'][opts.port[i]] = PlomWebSocketServer
+ elif server_type == 'tcp':
+ config['servers'][opts.port[i]] = PlomTCPServer
+ elif server_type == 'tcp_ssl':
+ config['servers'][opts.port[i]] = PlomTCPServerSSL
+ return config
+
+config = parse_command_line_arguments()
#!/usr/bin/env python3
from plomrogue.game import Game
-from plomrogue.io_websocket import PlomWebSocketServer
-from plomrogue.io_tcp import PlomTCPServer
from plomrogue.commands import (cmd_ALL, cmd_LOGIN, cmd_NICK, cmd_PING, cmd_THING,
cmd_MAP, cmd_TURN, cmd_MAP_LINE, cmd_GET_ANNOTATION,
cmd_ANNOTATE, cmd_PORTAL, cmd_GET_GAMESTATE,
from plomrogue.tasks import (Task_WAIT, Task_MOVE, Task_WRITE, Task_PICK_UP,
Task_DROP, Task_FLATTEN_SURROUNDINGS)
from plomrogue.things import Thing_Player, Thing_Item, Thing_Furniture
-import sys
-if len(sys.argv) != 2:
- print('wrong number of arguments, expected one (save file)')
- exit(1)
-savefile = sys.argv[1]
-game = Game(savefile)
+from plomrogue.config import config
+game = Game(config['savefile'])
game.register_command(cmd_PING)
game.register_command(cmd_ALL)
game.register_command(cmd_LOGIN)
game.register_thing_type(Thing_Furniture)
game.read_savefile()
game.io.start_loop()
-game.io.start_server(8000, PlomWebSocketServer)
-game.io.start_server(5000, PlomTCPServer)
+for port in config['servers']:
+ game.io.start_server(port, config['servers'][port],
+ config['certfile'], config['keyfile'])
import queue
import threading
import time
+import sys
from plomrogue.game import GameBase
from plomrogue.parser import Parser
from plomrogue.mapping import YX, MapGeometrySquare, MapGeometryHex
elif key in self.movement_keys:
move_explorer(self.movement_keys[key])
-#TUI('localhost:5000')
-TUI('wss://plomlompom.com/rogue_chat/')
+if len(sys.argv) != 2:
+ raise ArgError('wrong number of arguments, need game host')
+host = sys.argv[1]
+TUI(host)
python3 -m venv .venv
. .venv/bin/activate
pip install -r requirements_client.txt
-./rogue_chat_curses.py
+./rogue_chat_curses.py 'wss://plomlompom.com/rogue_chat/'