Work on inventory management

This commit is contained in:
2021-11-30 20:11:03 +00:00
parent 3754627e0d
commit 42d7ca3ba8
8 changed files with 154 additions and 85 deletions
+14 -2
View File
@@ -48,8 +48,20 @@ you w = _creatures w IM.! _yourID w
aCrPos :: Int -> World -> Point2
aCrPos i w = _crPos $ _creatures w IM.! i
yourItem :: World -> Item
yourItem w = _crInv (you w) IM.! _crInvSel (you w)
yourItem :: World -> Maybe Item
yourItem w = _crInv (you w) IM.!? _crInvSel (you w)
yourInv :: World -> IM.IntMap Item
yourInv w = _crInv (you w)
yourInvSel :: World -> Int
yourInvSel w = _crInvSel (you w)
selectedObject :: World -> Maybe (Either FloorItem Button)
selectedObject w = lookup (_crInvSel ycr) $ zip [n..] $ _closeObjects w
where
ycr = you w
n = length $ _crInv ycr
crItem :: World -> Int -> Item
crItem w cid = _crInv cr IM.! _crInvSel cr