Files
loop/src/Dodge/Inventory/Path.hs
T
2025-08-25 10:21:59 +01:00

20 lines
592 B
Haskell

module Dodge.Inventory.Path (getInventoryPath) where
import NewInt
import Dodge.Data.Creature
import qualified Data.IntMap.Strict as IM
import Control.Lens
import Control.Monad
getInventoryPath :: Int -> InventoryPathing -> Int -> Creature -> Maybe Int
getInventoryPath x ip itid cr = case ip of
ABSOLUTE -> checkinvid x
RELCURS -> do
selid <- cr ^? crManipulation . manObject . imSelectedItem . unNInt
checkinvid (x + selid)
RELITEM -> checkinvid (itid + x)
where
checkinvid y = do
guard $ y `IM.member` (cr ^. crInv . unNIntMap)
return y