From e74ac9f4c4757fb218b808f7d535961b362bfd1a Mon Sep 17 00:00:00 2001 From: justin Date: Thu, 17 Feb 2022 23:27:10 +0000 Subject: [PATCH] Cleanup --- src/Dodge/Creature/Impulse/UseItem.hs | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/Dodge/Creature/Impulse/UseItem.hs b/src/Dodge/Creature/Impulse/UseItem.hs index 911140094..712ae4da1 100644 --- a/src/Dodge/Creature/Impulse/UseItem.hs +++ b/src/Dodge/Creature/Impulse/UseItem.hs @@ -39,26 +39,12 @@ toggleEquipmentAt invid cr = cr & crInvEquipped . at invid %~ f f Nothing = Just () f (Just ()) = Nothing ---this is ugly useLeftItem :: Int -> World -> World useLeftItem cid w - | _crInvLock $ _creatures w IM.! cid = w - | otherwise = useLeftItem' cid w - - -useLeftItem' :: Int -> World -> World -useLeftItem' cid w = case cr ^? crInv . ix crinvsel . itUse of --- Just EquipUse{} -> w --- & lSelHammerPosition .~ HammerDown --- & case _lSelHammerPosition w of --- HammerUp -> creatures . ix cid %~ toggleEquipmentAt crinvsel --- _ -> id --- Just LeftUse {_lUse = f} -> f cr crinvsel (w & creatures . ix cid . crLeftInvSel ?~ crinvsel) - _ -> case _crLeftInvSel cr of - Just invid -> case _itUse $ _crInv cr IM.! invid of - LeftUse {_lUse = f} -> f cr invid w - _ -> w & creatures . ix cid . crLeftInvSel .~ Nothing - Nothing -> w + | _crInvLock cr = w + | otherwise = fromMaybe w $ do + invid <- _crLeftInvSel cr + f <- cr ^? crInv . ix invid . itUse . lUse + return $ f cr invid w where - crinvsel = _crInvSel cr cr = _creatures w IM.! cid