Commit before tweaking item id/locations

This commit is contained in:
2024-09-22 13:58:00 +01:00
parent efd3e17cbf
commit 236f7c7750
9 changed files with 28 additions and 19 deletions
+10
View File
@@ -62,6 +62,7 @@ rmInvItem cid invid w = w
& updateselection
& pointcid %~ updateRootItemID
& worldEventFlags . at InventoryChange ?~ ()
& updateCreatureItemLocations cid
where
pointcid = cWorld . lWorld . creatures . ix cid
@@ -94,6 +95,15 @@ rmInvItem cid invid w = w
| x > invid || Just x == maxk = max 0 $ x - 1
| otherwise = x
updateCreatureItemLocations :: Int -> World -> World
updateCreatureItemLocations crid w = fromMaybe w $ do
inv <- w ^? cWorld . lWorld . creatures . ix crid . crInv
return $ foldl' updateItemLocation w inv
updateItemLocation :: World -> Item -> World
updateItemLocation w itm = w
& cWorld . lWorld . itemLocations . ix (itm ^. itID) .~ itm ^. itLocation
---- | after this the item at the inventory position will no longer exist
--rmInvItem ::
-- -- | Creature id