about summary refs log tree commit diff
path: root/users/grfn/xanthous/src/Xanthous
diff options
context:
space:
mode:
Diffstat (limited to 'users/grfn/xanthous/src/Xanthous')
-rw-r--r--users/grfn/xanthous/src/Xanthous/App.hs32
1 files changed, 23 insertions, 9 deletions
diff --git a/users/grfn/xanthous/src/Xanthous/App.hs b/users/grfn/xanthous/src/Xanthous/App.hs
index fdc648dda42e..32f03e8392ef 100644
--- a/users/grfn/xanthous/src/Xanthous/App.hs
+++ b/users/grfn/xanthous/src/Xanthous/App.hs
@@ -59,7 +59,7 @@ import           Xanthous.Entities.Common
                  , wieldableItem, wieldedItems, wielded, itemsWithPosition
                  , removeItemFromPosition, asWieldedItem
                  , wieldedItem, items, Hand (..), describeHand, wieldInHand
-                 , WieldedItem
+                 , WieldedItem, Wielded (..)
                  )
 import qualified Xanthous.Entities.Character as Character
 import           Xanthous.Entities.Character hiding (pickUpItem)
@@ -296,8 +296,9 @@ handleCommand DescribeInventory = do
 
 
 handleCommand Wield = do
+  hs <- use $ character . inventory . wielded
   selectItem $ \(MenuResult (item :: WieldedItem)) -> do
-    selectHand $ \(MenuResult hand) -> do
+    selectHand hs $ \(MenuResult hand) -> do
       prevItems <- character . inventory . wielded %%= wieldInHand hand item
       character . inventory . backpack
         <>= fromList (map (view wieldedItem) prevItems)
@@ -309,13 +310,26 @@ handleCommand Wield = do
     selectItem =
       takeItemFromInventory_ ["wield", "menu"] Cancellable asWieldedItem
         (say_ ["wield", "nothing"])
-    selectHand
-      = menu_
-      ["wield", "hand"]
-      Cancellable
-      handsMenu
-    handsMenu = mapFromList
-      . map (second $ MenuOption =<< describeHand)
+    selectHand hs = menu_ ["wield", "hand"] Cancellable $ handsMenu hs
+    itemsInHand (Hands i _) LeftHand       = toList i
+    itemsInHand (DoubleHanded _) LeftHand  = []
+    itemsInHand (Hands _ i) RightHand      = toList i
+    itemsInHand (DoubleHanded _) RightHand = []
+    itemsInHand (Hands l r) BothHands      = toList l <> toList r
+    itemsInHand (DoubleHanded i) BothHands = [i]
+    describeItems [] = ""
+    describeItems is
+      = " (currently holding "
+      <> (intercalate " and" $ map (view $ wieldedItem . to description) is)
+      <> ")"
+    handsMenu hs = mapFromList
+      . map (second $ \hand ->
+                MenuOption
+                ( describeHand hand
+                <> describeItems (itemsInHand hs hand)
+                )
+                hand
+            )
       $ [ ('l', LeftHand)
         , ('r', RightHand)
         , ('b', BothHands)