diff options
| author | troido <troido@protonmail.com> | 2019-09-16 21:57:46 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2019-09-16 21:57:46 +0200 |
| commit | 32f1eddbc840a96ad3d713c138fa29012dd5006d (patch) | |
| tree | 671dd9324e13db034877a51fbfaead39f1e99aae /asciifarm/client/start.py | |
| parent | b40857345cdb42bb2c0e63d6c028c2f430d7e2a0 (diff) | |
put initialisation code in somewhat more sensible modules
Diffstat (limited to 'asciifarm/client/start.py')
| -rw-r--r-- | asciifarm/client/start.py | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/asciifarm/client/start.py b/asciifarm/client/start.py deleted file mode 100644 index 0c247b5..0000000 --- a/asciifarm/client/start.py +++ /dev/null @@ -1,52 +0,0 @@ - -import curses -import json -import os -import getpass -import sys -from .connection import Connection -from .gameclient import Client -from .display.display import Display - -defaultAdresses = { - "abstract": "asciifarm", - "unix": "asciifarm.socket", - "inet": "localhost:9021", - } - -def main(name, socketType, address, keybindings, characters, colours=False, logfile=None): - - connection = Connection(socketType) - try: - connection.connect(address) - except ConnectionRefusedError: - print("ERROR: Could not connect to server.\nAre you sure that the server is running and that you're connecting to the right address?", file=sys.stderr) - return - - error = None - closeMessage = None - - os.environ.setdefault("ESCDELAY", "25") - - def start(stdscr): - display = Display(stdscr, characters, colours) - client = Client(stdscr, display, name, connection, keybindings, logfile) - try: - client.start() - except KeyboardInterrupt: - client.close("^C caught, goodbye") - except Exception as e: - # throw the execption outside ncurses - # so the cleanup can happen first - nonlocal error - error = e - nonlocal closeMessage - closeMessage = client.closeMessage - - curses.wrapper(start) - - if error is not None: - raise error - - if closeMessage: - print(closeMessage, file=sys.stderr) |
