summaryrefslogtreecommitdiff
path: root/asciifarm/client
diff options
context:
space:
mode:
Diffstat (limited to 'asciifarm/client')
-rw-r--r--asciifarm/client/gameclient.py8
-rwxr-xr-xasciifarm/client/main.py11
2 files changed, 11 insertions, 8 deletions
diff --git a/asciifarm/client/gameclient.py b/asciifarm/client/gameclient.py
index 9ba4b37..914d90c 100644
--- a/asciifarm/client/gameclient.py
+++ b/asciifarm/client/gameclient.py
@@ -13,11 +13,12 @@ import string
from .display.display import Display
import hy
+from . import keybindings as defaultkeybindings
import importlib
class Client:
- def __init__(self, stdscr, display, name, connection, keybindings, logFile=None):
+ def __init__(self, stdscr, display, name, connection, keybindings=None, logFile=None):
self.stdscr = stdscr
self.display = display
self.name = name
@@ -25,8 +26,9 @@ class Client:
self.connection = connection
self.logFile = logFile
-
- keymodule = importlib.import_module(".keybindings", __package__)
+ keymodule = defaultkeybindings
+ if keybindings:
+ keymodule = importlib.import_module(keybindings)
self.commands = keymodule.commands
self.controlsString = keymodule.docs
diff --git a/asciifarm/client/main.py b/asciifarm/client/main.py
index 365c647..274a6df 100755
--- a/asciifarm/client/main.py
+++ b/asciifarm/client/main.py
@@ -35,7 +35,7 @@ def main(argv=None):
parser.add_argument('-n', '--name', help='Your player name (must be unique!). Defaults to username', default=getpass.getuser())
parser.add_argument("-a", "--address", help="The address of the socket. When the socket type is 'abstract' this is just a name. When it is 'unix' this is a filename. When it is 'inet' is should be in the format 'address:port', eg 'localhost:8080'. Defaults depends on the socket type")
parser.add_argument("-s", "--socket", help="the socket type. 'unix' is unix domain sockets, 'abstract' is abstract unix domain sockets and 'inet' is inet sockets. ", choices=["abstract", "unix", "inet"], default="abstract")
- parser.add_argument('-k', '--keybindings', help='The file with the keybindings. If it is either of these names: {} it will be loaded from the keybindings directory.'.format(standardKeyFiles), default="default")
+ parser.add_argument('-k', '--keybindings', help='The script with the keybindings. This can be either a python3 or a hy script.')
parser.add_argument('-c', '--characters', help='The file with the character mappings for the graphics. If it is either of these names: {} it will be loaded from the charmaps directory.'.format(standardCharFiles), default="default")
parser.add_argument('-o', '--logfile', help='All game messages will be written to this file.'.format(standardCharFiles), default=None)
@@ -50,10 +50,11 @@ def main(argv=None):
with open(charFile, 'r') as cf:
charMap = json.load(cf)
keyFile = args.keybindings
- if keyFile in standardKeyFiles:
- keyFile = os.path.join(keybindingsPath, keyFile + ".json")
- with open(keyFile, 'r') as kf:
- keybindings = json.load(kf)
+ if keyFile:
+ with open(keyFile, 'r') as kf:
+ keybindings = json.load(kf)
+ else:
+ keybindings = None
address = args.address
if address == None: