Separate out concrete part of world

This commit is contained in:
2022-07-25 12:10:50 +01:00
parent 3354d108be
commit b2efbd2b3e
134 changed files with 933 additions and 930 deletions
+5 -5
View File
@@ -11,7 +11,7 @@ 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 w IM.! flid) w
(i,w') <- tryPutItemInInv cid (_floorItems (_cWorld w) IM.! flid) w
return (Just i,w')
putItemInInvSlot :: Int -> Item -> IM.IntMap Item -> IM.IntMap Item
@@ -23,15 +23,15 @@ tryPutItemInInv cid flit w = case maybeInvSlot of
Nothing -> Nothing
Just i -> Just (i, w
& updateItLocation i
& floorItems %~ IM.delete (_flItID flit)
& creatures . ix cid . crInv %~ putItemInInvSlot i it
& cWorld . floorItems %~ IM.delete (_flItID flit)
& cWorld . creatures . ix cid . crInv %~ putItemInInvSlot i it
)
where
it = _flIt flit
maybeInvSlot = checkInvSlotsYou it w
updateItLocation invid w' = case _itID it of
Nothing -> w'
Just j -> w' & itemPositions . ix j .~ InInv cid invid
Just j -> w' & cWorld . itemPositions . ix j .~ InInv cid invid
--{- | Pick up a specific item. -}
--putItemInInv :: Int -> FloorItem -> World -> World
@@ -48,5 +48,5 @@ tryPutItemInInv cid flit w = case maybeInvSlot of
-- Nothing -> w'
-- Just j -> w' & itemPositions . ix j .~ InInv cid invid
createPutItem :: Item -> World -> (Maybe Int, World)
createPutItem it w = uncurry (putItemInInvID (_yourID w))
createPutItem it w = uncurry (putItemInInvID (_yourID (_cWorld w)))
$ copyItemToFloorID (_crPos $ you w) (applyModules it) w