Tweak inventory management

This commit is contained in:
2021-12-01 01:55:20 +00:00
parent 0ed260c9b7
commit b9e4a80a46
12 changed files with 138 additions and 109 deletions
+4 -11
View File
@@ -4,6 +4,9 @@
Basic helpers.
Consider splitting. -}
module Dodge.Base
( module Dodge.Base
, module Dodge.Base.You
)
where
import Dodge.Data
import Dodge.WinScale
@@ -14,6 +17,7 @@ import Geometry
--import Picture
import qualified IntMapHelp as IM
import FoldableHelp
import Dodge.Base.You
import Control.Lens
import qualified Control.Foldl as L
@@ -42,20 +46,9 @@ errorHead :: String -> [a] -> a
errorHead _ (x:_) = x
errorHead s [] = error s
you :: World -> Creature
you w = _creatures w IM.! _yourID w
aCrPos :: Int -> World -> Point2
aCrPos i w = _crPos $ _creatures w IM.! i
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