diff options
| author | troido <troido@hotmail.com> | 2017-12-29 22:10:16 +0100 |
|---|---|---|
| committer | troido <troido@hotmail.com> | 2017-12-29 22:10:16 +0100 |
| commit | a1c60cfcb63b013f575943e17854cf205f8db913 (patch) | |
| tree | ad3829ef22dab6e9082728dc400b14eb06d94fdc /asciifarm/client/gameclient.py | |
| parent | 26c5eb315a4512a53a51a85abf4c0385b978c2f5 (diff) | |
made selectors for inventorypad and made key config in hy
Diffstat (limited to 'asciifarm/client/gameclient.py')
| -rw-r--r-- | asciifarm/client/gameclient.py | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/asciifarm/client/gameclient.py b/asciifarm/client/gameclient.py index b4cd259..fb030d5 100644 --- a/asciifarm/client/gameclient.py +++ b/asciifarm/client/gameclient.py @@ -12,6 +12,8 @@ from .display.screen import Screen import string from .display.display import Display +import hy +import importlib class Client: @@ -23,17 +25,7 @@ class Client: self.connection = connection self.logFile = logFile - self.commands = {} - if "input" in keybindings: - for key, commands in keybindings["input"].items(): - if isinstance(commands[0], str): - commands = [commands] - self.commands[key] = [("send", ["input", command]) for command in commands] - if "control" in keybindings: - for key, commands in keybindings["control"].items(): - if isinstance(commands[0], str): - commands = [commands] - self.commands[key] = commands + self.commands = importlib.import_module(".keybindings", __package__).commands self.controlsString = """\ Default Controls: @@ -48,11 +40,12 @@ Default Controls: self.display.showInfo(self.controlsString) - self.actions = { - "send": (lambda data: self.connection.send(json.dumps(data))), - "text": (lambda: self.readString()) - } + def send(self, data): + self.connection.send(json.dumps(data)) + + def getDisplay(self): + return self.display def readString(self): text = self.display.getString() @@ -139,8 +132,7 @@ Default Controls: except ValueError: continue if keyname in self.commands: - for command, *data in self.commands[keyname]: - self.actions[command](*data) + self.commands[keyname](self) |
