Major item refactor, still broken
This commit is contained in:
@@ -36,9 +36,9 @@ tryPutItemInInv cid itid w = do
|
||||
return $ (invid,) $ w
|
||||
& cWorld . lWorld %~ crUpdateItemLocations cid
|
||||
-- not sure about the order of these...
|
||||
& cWorld . lWorld . creatures . ix cid . crInv . at invid ?~ newitm
|
||||
& cWorld . lWorld . creatures . ix cid . crInv . at invid ?~ itid
|
||||
& cWorld . lWorld . items . at itid ?~ newitm
|
||||
& cWorld . lWorld . itemLocations . at itid ?~ itloc
|
||||
-- & cWorld . lWorld . itemLocations . at itid ?~ itloc
|
||||
& cWorld . lWorld . floorItems . at itid .~ Nothing
|
||||
& updateselectionextra
|
||||
where
|
||||
@@ -110,13 +110,10 @@ tryPutItemInInvAt i cid itid w = do
|
||||
-- copyItemToFloorID (_crPos $ you w) (applyModules it) w
|
||||
-- return (Just i, w')
|
||||
|
||||
createItemYou :: Item -> World -> (ItemLocation, World)
|
||||
createItemYou itm w = fromMaybe (OnFloor, w') $ do
|
||||
(invid, w'') <- tryPutItemInInv 0 itid w'
|
||||
itloc <- w'' ^? cWorld . lWorld . creatures . ix 0 . crInv . ix invid . itLocation
|
||||
return (itloc, w'')
|
||||
createItemYou :: Item -> World -> World
|
||||
createItemYou itm w = fromMaybe w' $ fmap snd $ tryPutItemInInv 0 itid w'
|
||||
where
|
||||
itid = IM.newKey $ w ^. cWorld . lWorld . itemLocations
|
||||
itid = IM.newKey $ w ^. cWorld . lWorld . items
|
||||
pos = w ^?! cWorld . lWorld . creatures . ix 0 . crPos
|
||||
w' = copyItemToFloorID pos (itm & itID .~ NInt itid) w
|
||||
|
||||
|
||||
Reference in New Issue
Block a user