Improve machines, tweak wall ids

This commit is contained in:
2021-11-01 15:21:21 +00:00
parent 7692421112
commit 7ddbbdda14
11 changed files with 76 additions and 28 deletions
+11
View File
@@ -1,10 +1,21 @@
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