Work on what happens when creatures fall down chasms

This commit is contained in:
2025-08-05 21:39:44 +01:00
parent df443744db
commit f69956750a
9 changed files with 112 additions and 109 deletions
+13 -8
View File
@@ -13,6 +13,7 @@ module Dodge.Inventory (
swapInvItems,
scrollAugNextInSection,
swapItemWith,
destroyItem,
) where
import Dodge.Equipment
@@ -60,14 +61,18 @@ destroyInvItem cid invid w =
(cWorld . lWorld . imHotkeys . unNIntMap . at itid .~ Nothing)
. (cWorld . lWorld . hotkeys . at hk .~ Nothing)
-- | after this the item at the inventory position will no longer exist
rmInvItem ::
-- | Creature id
Int ->
-- | Inventory position
Int ->
World ->
World
destroyItem :: Int -> World -> World
destroyItem itid w = case w ^? cWorld . lWorld . itemLocations . ix itid of
Nothing -> error $ "Tried to destroy item that does not exist; item id: "++ show itid
Just (InInv {_ilCrID = cid, _ilInvID = invid}) -> destroyInvItem cid invid w
Just (OnTurret{}) -> error "need to write code for destroying items on turrets"
Just (OnFloor (NInt i)) -> w & cWorld . lWorld . itemLocations . at itid .~ Nothing
& cWorld . lWorld . floorItems . unNIntMap . at i .~ Nothing
Just InVoid -> w & cWorld . lWorld . itemLocations . at itid .~ Nothing
-- note rmInvItem does not fully destroy the item, other updates to the item
-- location are required
rmInvItem :: Int -> Int -> World -> World
rmInvItem cid invid w =
w
& dounequipfunction --the ordering of these is