From a843a1c9c0836fec3675ad1b77402c533a6e0498 Mon Sep 17 00:00:00 2001 From: justin Date: Wed, 8 Jan 2025 14:30:02 +0000 Subject: [PATCH] Add file --- src/Dodge/Inventory/Path.hs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/Dodge/Inventory/Path.hs diff --git a/src/Dodge/Inventory/Path.hs b/src/Dodge/Inventory/Path.hs new file mode 100644 index 000000000..1efca8945 --- /dev/null +++ b/src/Dodge/Inventory/Path.hs @@ -0,0 +1,18 @@ +module Dodge.Inventory.Path (getInventoryPath) where + +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 | x `IM.member` (cr ^. crInv) -> Just x + RELCURS -> do + selid <- cr ^? crManipulation . manObject . imSelectedItem + guard $ (x + selid) `IM.member` (cr ^. crInv) + return $ (x + selid) + RELITEM + | (itid + x) `IM.member` (cr ^. crInv) -> + return $ itid + x + _ -> Nothing