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
+7
View File
@@ -66,6 +66,11 @@ data Creature = Creature
--deriving (Eq, Ord, Show, Read) --Generic, Flat)
data CrHP
= HP Int
| CrIsCorpse
| CrIsGibs
data Intention = Intention
{ _targetCr :: Maybe Creature
, _mvToPoint :: Maybe Point2
@@ -76,10 +81,12 @@ data Intention = Intention
makeLenses ''Creature
makeLenses ''Intention
makePrisms ''CrHP
concat
<$> mapM
(deriveJSON defaultOptions)
[ ''Creature
, ''Intention
, ''CrHP
]
+1
View File
@@ -36,6 +36,7 @@ data ProximitySensorType
data ProximityRequirement
= RequireHealth {_proxReqMinHealth :: Int}
| RequireEquipment {_proxReqEquipment :: ItemType}
| RequireDeadCreatures {_proxReqDead :: [Int]}
deriving (Show)
makeLenses ''DamageSensor
+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