diff options
author | Griffin Smith <grfn@gws.fyi> | 2022-05-01T19·51-0400 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2022-05-14T15·59+0000 |
commit | 1ce67611b54871c7541396399da35e0b8d69f2f5 (patch) | |
tree | c0882d92089b68b9ab21bbdd056172a6350a9fc9 /users/grfn/xanthous/src/Xanthous | |
parent | 2b2f959981fbde601a8103fe3718feaa688fe37a (diff) |
feat(grfn/xanthous): Describe items in hand when wielding r/4069
Describe the items already in the hand when prompting for which hand to wield an item in Change-Id: Ifdf2703e8695aae5cbf06a3195fb790428954012 Reviewed-on: https://cl.tvl.fyi/c/depot/+/5509 Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi> Autosubmit: grfn <grfn@gws.fyi>
Diffstat (limited to 'users/grfn/xanthous/src/Xanthous')
-rw-r--r-- | users/grfn/xanthous/src/Xanthous/App.hs | 32 |
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) |