20 lines
592 B
Haskell
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
|