Use getInventoryPath in useInventoryPath
This commit is contained in:
+16
-12
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user