Use getInventoryPath in useInventoryPath

This commit is contained in:
2026-05-18 15:49:03 +01:00
parent 9fb5a4e0be
commit 3119f10c2c
2 changed files with 18 additions and 14 deletions
+16 -12
View File
@@ -1416,18 +1416,22 @@ useInventoryPath ::
Creature ->
World ->
World
useInventoryPath pt i ip loc cr w = case ip of
ABSOLUTE -> fromMaybe w $ useat i
RELCURS -> fromMaybe w $ do
Sel 0 j <- w ^? hud .diSelection._Just
useat $ i + j
RELITEM -> fromMaybe w $ do
j <- loc ^? locDT . dtValue . _1 . itLocation . ilInvID . unNInt
useat $ i + j
where
useat k = do
guard $ k `IM.member` (cr ^. crInv . unNIntMap)
return $ w & cWorld . lWorld . delayedEvents .:~ (1, UseInvItem k pt)
useInventoryPath pt i ip loc cr w = fromMaybe w $ do
invid <- loc ^? locDT . dtValue . _1 . itLocation . ilInvID . unNInt
j <- getInventoryPath w i ip invid cr
return $ w & cWorld . lWorld . delayedEvents .:~ (1,UseInvItem j pt)
-- = case ip of
-- ABSOLUTE -> fromMaybe w $ useat i
-- RELCURS -> fromMaybe w $ do
-- Sel 0 j <- w ^? hud .diSelection._Just
-- useat $ i + j
-- RELITEM -> fromMaybe w $ do
-- j <- loc ^? locDT . dtValue . _1 . itLocation . ilInvID . unNInt
-- useat $ i + j
-- where
-- useat k = do
-- guard $ k `IM.member` (cr ^. crInv . unNIntMap)
-- return $ w & cWorld . lWorld . delayedEvents .:~ (1, UseInvItem k pt)
--useRewindGun _ _ w = case w ^. cwTime . rewindWorlds of
+2 -2
View File
@@ -7,12 +7,12 @@ import Control.Lens
import Control.Monad
getInventoryPath :: World -> Int -> InventoryPathing -> Int -> Creature -> Maybe Int
getInventoryPath w x ip itid cr = case ip of
getInventoryPath w x ip invid cr = case ip of
ABSOLUTE -> checkinvid x
RELCURS -> do
Sel 0 selid <- w ^? hud .diSelection._Just
checkinvid (x + selid)
RELITEM -> checkinvid (itid + x)
RELITEM -> checkinvid (invid + x)
where
checkinvid y = do
guard $ y `IM.member` (cr ^. crInv . unNIntMap)