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 -> Creature ->
World -> World ->
World World
useInventoryPath pt i ip loc cr w = case ip of useInventoryPath pt i ip loc cr w = fromMaybe w $ do
ABSOLUTE -> fromMaybe w $ useat i invid <- loc ^? locDT . dtValue . _1 . itLocation . ilInvID . unNInt
RELCURS -> fromMaybe w $ do j <- getInventoryPath w i ip invid cr
Sel 0 j <- w ^? hud .diSelection._Just return $ w & cWorld . lWorld . delayedEvents .:~ (1,UseInvItem j pt)
useat $ i + j -- = case ip of
RELITEM -> fromMaybe w $ do -- ABSOLUTE -> fromMaybe w $ useat i
j <- loc ^? locDT . dtValue . _1 . itLocation . ilInvID . unNInt -- RELCURS -> fromMaybe w $ do
useat $ i + j -- Sel 0 j <- w ^? hud .diSelection._Just
where -- useat $ i + j
useat k = do -- RELITEM -> fromMaybe w $ do
guard $ k `IM.member` (cr ^. crInv . unNIntMap) -- j <- loc ^? locDT . dtValue . _1 . itLocation . ilInvID . unNInt
return $ w & cWorld . lWorld . delayedEvents .:~ (1, UseInvItem k pt) -- 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 --useRewindGun _ _ w = case w ^. cwTime . rewindWorlds of
+2 -2
View File
@@ -7,12 +7,12 @@ import Control.Lens
import Control.Monad import Control.Monad
getInventoryPath :: World -> Int -> InventoryPathing -> Int -> Creature -> Maybe Int 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 ABSOLUTE -> checkinvid x
RELCURS -> do RELCURS -> do
Sel 0 selid <- w ^? hud .diSelection._Just Sel 0 selid <- w ^? hud .diSelection._Just
checkinvid (x + selid) checkinvid (x + selid)
RELITEM -> checkinvid (itid + x) RELITEM -> checkinvid (invid + x)
where where
checkinvid y = do checkinvid y = do
guard $ y `IM.member` (cr ^. crInv . unNIntMap) guard $ y `IM.member` (cr ^. crInv . unNIntMap)