From b5105034791a2af1bd9370aeb0aa741300e0641b Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sun, 1 May 2022 15:58:36 -0400 Subject: 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 Autosubmit: grfn --- users/grfn/xanthous/src/Xanthous/App.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'users/grfn/xanthous/src') diff --git a/users/grfn/xanthous/src/Xanthous/App.hs b/users/grfn/xanthous/src/Xanthous/App.hs index 32f03e8392ef..4ae549d15983 100644 --- a/users/grfn/xanthous/src/Xanthous/App.hs +++ b/users/grfn/xanthous/src/Xanthous/App.hs @@ -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 -- cgit 1.4.1