diff options
| author | troido <troido@hotmail.com> | 2017-10-27 22:18:51 +0200 |
|---|---|---|
| committer | troido <troido@hotmail.com> | 2017-10-27 22:18:51 +0200 |
| commit | 687bc04dd7988b2b9a34e91397f948c6fa44aad9 (patch) | |
| tree | 4d1c05c36cb480bc1a45ddc7508e2b38a4368b56 /asciifarm/client/client.py | |
| parent | b821aa6cc7e4bd137eb57a0ccebb5b514eb0031b (diff) | |
merged master changes from today into package branch
Diffstat (limited to 'asciifarm/client/client.py')
| -rw-r--r-- | asciifarm/client/client.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/asciifarm/client/client.py b/asciifarm/client/client.py index 5ad91e0..d6e2595 100644 --- a/asciifarm/client/client.py +++ b/asciifarm/client/client.py @@ -24,11 +24,15 @@ class Client: self.keepalive = True self.connection = connection - self.commands = {ord(key): command for key, command in keybindings['input'].items()} + self.commands = {} + for key, commands in keybindings["input"].items(): + if isinstance(commands[0], str): + commands = [commands] + self.commands[ord(key)] = [["input", command] for command in commands] self.controlsString = "Controls:\n"+'\n'.join( - chr(key) + ": " + ' '.join(action) - for key, action in self.commands.items() + chr(key) + ": " + ', '.join(' '.join(action[1]) for action in actions) + for key, actions in self.commands.items() if chr(key) in string.printable) self.display.showInfo(self.controlsString) @@ -67,6 +71,7 @@ class Client: field = msg[1] fieldWidth = field['width'] fieldHeight = field['height'] + self.display.resizeField((fieldWidth, fieldHeight)) fieldCells = field['field'] mapping = field['mapping'] self.display.drawFieldCells( @@ -81,7 +86,9 @@ class Client: self.display.setFieldCenter(msg[1]) if msgType == "health": - self.display.setHealth(*msg[1]) + health = msg[1] + if health: + self.display.setHealth(*health) if msgType == "inventory": self.display.setInventory(msg[1]) if msgType == "ground": @@ -96,7 +103,7 @@ class Client: if key == 27: self.keepalive = False if key in self.commands: - self.connection.send(json.dumps(["input", self.commands[key]])) + self.connection.send(json.dumps(self.commands[key])) |
