Control wall damage effects using the wall

This commit is contained in:
2021-11-01 16:50:09 +00:00
parent 7ddbbdda14
commit e4c73b9b8b
7 changed files with 93 additions and 57 deletions
-25
View File
@@ -1,25 +0,0 @@
module Dodge.WorldEvent.DamageBlock
( damageBlocksBy
, damageWall
) where
import Dodge.Data
import Dodge.Data.DamageType
import Control.Lens
damageWall :: DamageType -> Wall -> World -> World
damageWall dt wl = case _wlStructure wl of
MachinePart mcid -> machines . ix mcid . mcDamage %~ (dt :)
BlockPart blid -> blocks . ix blid %~ damageBlockWith dt
_ -> id
damageBlockWith :: DamageType -> Block -> Block
damageBlockWith _ = id
damageBlocksBy :: Int -> Wall -> World -> World
damageBlocksBy x wl = case wl ^? wlStructure . wlStBlock of
Just blid -> blocks . ix blid . blHPs %~ reduceHeadBy x
Nothing -> id
where
reduceHeadBy y (z:zs) = z - y : zs
reduceHeadBy _ [] = []
+1 -1
View File
@@ -6,7 +6,7 @@ module Dodge.WorldEvent.Shockwave
import Dodge.Data
import Dodge.Data.DamageType
import Dodge.Creature.State.Data
import Dodge.WorldEvent.DamageBlock
import Dodge.Wall.Damage
import Dodge.Base
import Dodge.Zone
import Dodge.Picture.Layer