diff options
| author | troido <troido@hotmail.com> | 2017-12-30 12:49:28 +0100 |
|---|---|---|
| committer | troido <troido@hotmail.com> | 2017-12-30 12:49:28 +0100 |
| commit | 705bc3ea52c52f13bddf0946bdb77a5a3fef77c6 (patch) | |
| tree | 00cabf5e7b0003d3750aa6e57544ef1416d8543b /asciifarm | |
| parent | b63f38d654814d6be7a56ee7c8c6c6567755e0b4 (diff) | |
added equipment display
Diffstat (limited to 'asciifarm')
| -rw-r--r-- | asciifarm/client/display/display.py | 12 | ||||
| -rw-r--r-- | asciifarm/client/display/screen.py | 5 | ||||
| -rw-r--r-- | asciifarm/client/gameclient.py | 2 | ||||
| -rw-r--r-- | asciifarm/client/keybindings.hy | 3 |
4 files changed, 19 insertions, 3 deletions
diff --git a/asciifarm/client/display/display.py b/asciifarm/client/display/display.py index 79991af..1a2dca0 100644 --- a/asciifarm/client/display/display.py +++ b/asciifarm/client/display/display.py @@ -49,6 +49,8 @@ class Display: setwin(self.inventoryPad, "inventory") self.groundPad = InventoryPad("Ground") setwin(self.groundPad, "ground") + self.equipment = InventoryPad("Equipment") + setwin(self.equipment, "equipment") self.messagePad = MessagePad() setwin(self.messagePad, "msg") self.textInput = TextInput() @@ -58,7 +60,7 @@ class Display: #self.changed = False - self.update() + self.update(True) def getWidget(self, name): if name in self.widgets: @@ -93,6 +95,14 @@ class Display: self.inventoryPad.setInventory(items) #self.change() + def setEquipment(self, slots): + self.equipment.setInventory( + sorted([ + slot + ": " + (item if item else "") + for slot, item in slots.items() + ]) + ) + def setGround(self, items): self.groundPad.setInventory(items) #self.change() diff --git a/asciifarm/client/display/screen.py b/asciifarm/client/display/screen.py index 5eeb879..a09c2a9 100644 --- a/asciifarm/client/display/screen.py +++ b/asciifarm/client/display/screen.py @@ -32,7 +32,9 @@ class Screen: groundH = self._limitHeight(7, groundY) invY = groundY + groundH invH = self._limitHeight(12, invY) - infoY = invY + invH + eqY = invY + invH + eqH = self._limitHeight(5, eqY) + infoY = eqY + eqH infoH = self._limitHeight(20, infoY) self.windows = { @@ -42,6 +44,7 @@ class Screen: "health": self.makeWin(sideX, healthY, sideW, healthH), "ground": self.makeWin(sideX, groundY, sideW, groundH), "inventory": self.makeWin(sideX, invY, sideW, invH), + "equipment": self.makeWin(sideX, eqY, sideW, eqH), "info": self.makeWin(sideX, infoY, sideW, infoH) } diff --git a/asciifarm/client/gameclient.py b/asciifarm/client/gameclient.py index fb030d5..565262d 100644 --- a/asciifarm/client/gameclient.py +++ b/asciifarm/client/gameclient.py @@ -107,6 +107,8 @@ Default Controls: self.log("You have died. Restart the client to respawn") if msgType == "inventory": self.display.setInventory(msg[1]) + if msgType == "equipment": + self.display.setEquipment(msg[1]) if msgType == "ground": self.display.setGround(msg[1]) if msgType == "message": diff --git a/asciifarm/client/keybindings.hy b/asciifarm/client/keybindings.hy index d2b129f..579ca2c 100644 --- a/asciifarm/client/keybindings.hy +++ b/asciifarm/client/keybindings.hy @@ -17,7 +17,8 @@ "r" (input ["interact" (selectorvalue "ground")]) "v" (fn [client] (.select (selector "inventory") 1 True True)) "c" (fn [client] (.select (selector "ground") 1 True True)) -;; "x" (fn [client] (.select (selector "equipment") 1 True True)) + "x" (fn [client] (.select (selector "equipment") 1 True True)) + "z" (input ["unequip" (selectorvalue "equipment")]) "f" (doall [ (input ["attack"]) (input ["attack" "north"]) |
