Add destroyable lighting

This commit is contained in:
2021-03-27 11:59:34 +01:00
parent 151fa5b6bd
commit 2897c65e9e
7 changed files with 135 additions and 143 deletions
+10 -4
View File
@@ -77,11 +77,8 @@ doDamage cr = set (crState . crDamage) [] $ over (crState . crPastDamage) (+ hpL
where dams = _crDamage $ _crState cr
startHP = _crHP cr
damagedCr = snd $ (_crApplyDamage (_crState cr)) dams cr
-- applyDamage (cr ^. crState . crDamage) cr
afterHP = _crHP damagedCr
hpLost = startHP - afterHP -- note this can be negative
-- applyDamage :: DamageType -> Creature -> Creature
-- applyDamage dt cr = snd $ (cr ^. crState . crApplyDamage) dt cr
sumDamage :: Creature -> DamageType -> Int -> Int
sumDamage cr dm x = x + _dmAmount dm
@@ -184,11 +181,20 @@ decreaseToZero :: Int -> Int
decreaseToZero x | x > 0 = x - 1
| otherwise = 0
--comb :: (StdGen -> Creature -> World -> World) -> (StdGen -> Creature -> Maybe Creature)
-- -> CRUpdate
--comb
onDeath :: (Creature -> World -> World) -> CRUpdate -> CRUpdate
onDeath h u w (f,g) cr
| _crHP cr > 0 = u w (f,g) cr
| otherwise = ( ( h cr . f, g ) , Nothing )
updateBarrel ::
World -> (World -> World,StdGen) -> Creature -> ((World -> World , StdGen), Maybe Creature)
updateBarrel w (f,g) cr | _crHP cr > 0 = ((f, g), newCr)
| otherwise = ((f, g), Nothing)
-- | otherwise = ((makeExplosionAt (_crPos cr) . stopSounds , g'), Nothing)
where damages = _crDamage $ _crState cr
newCr = Just $ doDamage cr