Add in "linear" lWorld to separate time reversable worlds
This commit is contained in:
@@ -11,7 +11,8 @@ import qualified IntMapHelp as IM
|
||||
|
||||
putItemInInvID :: Int -> Int -> World -> (Maybe Int, World)
|
||||
putItemInInvID cid flid w = fromMaybe (Nothing, w) $ do
|
||||
(i, w') <- tryPutItemInInv cid (_floorItems (_cWorld w) IM.! flid) w
|
||||
--(i, w') <- tryPutItemInInv cid (_floorItems (_cWorld w) IM.! flid) w
|
||||
(i, w') <- tryPutItemInInv cid (w ^?! cWorld . lWorld . floorItems . ix flid) w
|
||||
return (Just i, w')
|
||||
|
||||
putItemInInvSlot :: Int -> Item -> IM.IntMap Item -> IM.IntMap Item
|
||||
@@ -26,13 +27,13 @@ tryPutItemInInv cid flit w = case maybeInvSlot of
|
||||
( i
|
||||
, w
|
||||
& updateItLocation i
|
||||
& cWorld . floorItems %~ IM.delete (_flItID flit)
|
||||
& cWorld . creatures . ix cid . crInv %~ putItemInInvSlot i it
|
||||
& cWorld . lWorld . floorItems %~ IM.delete (_flItID flit)
|
||||
& cWorld . lWorld . creatures . ix cid . crInv %~ putItemInInvSlot i it
|
||||
)
|
||||
where
|
||||
it = _flIt flit
|
||||
maybeInvSlot = checkInvSlotsYou it w
|
||||
updateItLocation invid w' = w' & cWorld . itemLocations . ix (_itID it) .~ InInv cid invid
|
||||
updateItLocation invid w' = w' & cWorld . lWorld . itemLocations . ix (_itID it) .~ InInv cid invid
|
||||
|
||||
--{- | Pick up a specific item. -}
|
||||
--putItemInInv :: Int -> FloorItem -> World -> World
|
||||
@@ -50,5 +51,5 @@ tryPutItemInInv cid flit w = case maybeInvSlot of
|
||||
-- Just j -> w' & itemPositions . ix j .~ InInv cid invid
|
||||
createPutItem :: Item -> World -> (Maybe Int, World)
|
||||
createPutItem it w =
|
||||
uncurry (putItemInInvID (_yourID (_cWorld w))) $
|
||||
uncurry (putItemInInvID (_yourID (_lWorld (_cWorld w)))) $
|
||||
copyItemToFloorID (_crPos $ you w) (applyModules it) w
|
||||
|
||||
Reference in New Issue
Block a user