Fix more item bugs
This commit is contained in:
@@ -111,7 +111,7 @@ tryPutItemInInvAt i cid itid w = do
|
||||
-- return (Just i, w')
|
||||
|
||||
createItemYou :: Item -> World -> World
|
||||
createItemYou itm w = w' -- fromMaybe w' $ fmap snd $ tryPutItemInInv 0 itid w'
|
||||
createItemYou itm w = fromMaybe w' $ fmap snd $ tryPutItemInInv 0 itid w'
|
||||
where
|
||||
itid = IM.newKey $ w ^. cWorld . lWorld . items
|
||||
pos = w ^?! cWorld . lWorld . creatures . ix 0 . crPos
|
||||
|
||||
@@ -45,9 +45,9 @@ updateRootItemID m cr = fromMaybe cr $ do
|
||||
crUpdateItemLocations :: Int -> LWorld -> LWorld
|
||||
crUpdateItemLocations crid lw = fromMaybe lw $ do
|
||||
mo <- lw ^? creatures . ix crid . crManipulation . manObject
|
||||
itids <- lw ^? creatures . ix crid . crInv
|
||||
cinv <- lw ^? creatures . ix crid . crInv
|
||||
--let crinv = IM.restrictKeys (lw ^. items) (IS.fromList $ IM.elems itids)
|
||||
let crinv = fmap (\k -> lw ^?! items . ix k) itids
|
||||
let crinv = fmap (\k -> lw ^?! items . ix k) cinv
|
||||
return $ crSetRoots crid $ IM.foldlWithKey' (crUpdateInvidLocations mo crid) lw crinv
|
||||
|
||||
crSetRoots :: Int -> LWorld -> LWorld
|
||||
@@ -65,8 +65,7 @@ crUpdateInvidLocations :: ManipulatedObject -> Int -> LWorld -> Int -> Item -> L
|
||||
crUpdateInvidLocations mo crid lw invid itm =
|
||||
lw
|
||||
& creatures . ix crid . crInv . ix invid .~ itid -- . itLocation .~ newloc
|
||||
& items . ix invid .~ (itm & itLocation .~ newloc)
|
||||
-- & itemLocations %~ IM.insert itid newloc
|
||||
& items . ix itid .~ (itm & itLocation .~ newloc)
|
||||
where
|
||||
itid = itm ^. itID . unNInt
|
||||
newloc =
|
||||
|
||||
Reference in New Issue
Block a user