Pitted creatures lose all items

This commit is contained in:
2025-08-05 21:47:32 +01:00
parent f69956750a
commit af5bdf59b9
3 changed files with 61 additions and 57 deletions
+2 -1
View File
@@ -2,6 +2,7 @@ module Dodge.Creature.Update (
updateCreature,
) where
import Dodge.Inventory
import LensHelp
import Geometry
import Dodge.SoundLogic
@@ -18,7 +19,7 @@ import qualified Data.List as List
updateCreature :: Creature -> World -> World
updateCreature cr
| _crZ cr < negate 100 = id -- can remove creature and all items
| _crZ cr < negate 100 = destroyAllInvItems cr
| _crZ cr < 0 = (tocr . crZVel -~ 0.5)
. (tocr . crZ +~ _crZVel cr)
| otherwise = updateCreature' cr
+6 -6
View File
@@ -14,6 +14,7 @@ module Dodge.Inventory (
scrollAugNextInSection,
swapItemWith,
destroyItem,
destroyAllInvItems,
) where
import Dodge.Equipment
@@ -41,12 +42,7 @@ import NewInt
-- should consider never fully destroying items, but assigning a flag saying how
-- they were moved from play
destroyInvItem ::
Int ->
-- | Inventory position
Int ->
World ->
World
destroyInvItem :: Int -> Int -> World -> World
destroyInvItem cid invid w =
rmInvItem cid invid w & removeitloc
& removeithotkey
@@ -61,6 +57,10 @@ destroyInvItem cid invid w =
(cWorld . lWorld . imHotkeys . unNIntMap . at itid .~ Nothing)
. (cWorld . lWorld . hotkeys . at hk .~ Nothing)
destroyAllInvItems :: Creature -> World -> World
destroyAllInvItems cr w = foldl' (flip $ destroyInvItem (cr ^. crID)) w
. reverse . IM.keys $ cr ^. crInv
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