Cleanup
This commit is contained in:
@@ -39,26 +39,12 @@ toggleEquipmentAt invid cr = cr & crInvEquipped . at invid %~ f
|
|||||||
f Nothing = Just ()
|
f Nothing = Just ()
|
||||||
f (Just ()) = Nothing
|
f (Just ()) = Nothing
|
||||||
|
|
||||||
--this is ugly
|
|
||||||
useLeftItem :: Int -> World -> World
|
useLeftItem :: Int -> World -> World
|
||||||
useLeftItem cid w
|
useLeftItem cid w
|
||||||
| _crInvLock $ _creatures w IM.! cid = w
|
| _crInvLock cr = w
|
||||||
| otherwise = useLeftItem' cid w
|
| otherwise = fromMaybe w $ do
|
||||||
|
invid <- _crLeftInvSel cr
|
||||||
|
f <- cr ^? crInv . ix invid . itUse . lUse
|
||||||
useLeftItem' :: Int -> World -> World
|
return $ f cr invid w
|
||||||
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
|
|
||||||
where
|
where
|
||||||
crinvsel = _crInvSel cr
|
|
||||||
cr = _creatures w IM.! cid
|
cr = _creatures w IM.! cid
|
||||||
|
|||||||
Reference in New Issue
Block a user