fix(grfn/xanthous): Don't remove items on cancel

Only remove items selected to wield from the inventory once they're
actually going to be wielded, to avoid cancelling the hand selection
from causing the item to disappear

Change-Id: I3c4010058ae18b205a68b035d5e189a10ffbd12c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5510
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Autosubmit: grfn <grfn@gws.fyi>
This commit is contained in:
Griffin Smith 2022-05-01 15:58:36 -04:00 committed by clbot
parent 1ce67611b5
commit b510503479

View file

@ -297,8 +297,10 @@ handleCommand DescribeInventory = do
handleCommand Wield = do
hs <- use $ character . inventory . wielded
selectItem $ \(MenuResult (item :: WieldedItem)) -> do
selectItem $ \(MenuResult (invPos, (item :: WieldedItem))) -> do
selectHand hs $ \(MenuResult hand) -> do
character . inventory
%= removeItemFromPosition invPos (asWieldedItem # item)
prevItems <- character . inventory . wielded %%= wieldInHand hand item
character . inventory . backpack
<>= fromList (map (view wieldedItem) prevItems)
@ -308,7 +310,7 @@ handleCommand Wield = do
continue
where
selectItem =
takeItemFromInventory_ ["wield", "menu"] Cancellable asWieldedItem
selectItemFromInventory_ ["wield", "menu"] Cancellable asWieldedItem
(say_ ["wield", "nothing"])
selectHand hs = menu_ ["wield", "hand"] Cancellable $ handsMenu hs
itemsInHand (Hands i _) LeftHand = toList i