Move toward not removing creatures on death

This commit is contained in:
2025-09-25 08:48:20 +01:00
parent 1f14f3d0c3
commit fcb02850d0
4 changed files with 34 additions and 19 deletions
+5
View File
@@ -17,6 +17,8 @@ import Dodge.Terminal
import Dodge.Terminal.Color
import Geometry
import LensHelp
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
updateMachine :: Machine -> World -> World
updateMachine mc
@@ -195,6 +197,7 @@ sensorReqToString :: ProximityRequirement -> String
sensorReqToString = \case
RequireHealth x -> "HEALTH ABOVE " ++ show x
RequireEquipment x -> itemBaseName x
RequireDeadCreatures is -> "CREATURES DESTROYED: " ++ show is
mcProxTest :: World -> ProximityRequirement -> Bool
mcProxTest w = \case
@@ -203,6 +206,8 @@ mcProxTest w = \case
any
(\itm -> _itType itm == ct)
((\k -> w ^?! cWorld . lWorld . items . ix k) <$> _crInv cr)
RequireDeadCreatures is -> all (\x -> _crHP x < 0)
(IM.restrictKeys (w ^. cWorld . lWorld . creatures) (IS.fromList is))
where
cr = you w