This commit is contained in:
2022-02-17 23:27:10 +00:00
parent c614a3a655
commit e74ac9f4c4
+5 -19
View File
@@ -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