Partially implement separate blocks
This commit is contained in:
@@ -1,16 +1,13 @@
|
||||
module Dodge.WorldEvent.DamageBlock
|
||||
( damageBlocksBy
|
||||
)
|
||||
where
|
||||
import Dodge.Data
|
||||
|
||||
import Data.Maybe
|
||||
import Control.Lens
|
||||
{- | Given a wall, if it is a damageable block
|
||||
- then damage it and connecting walls by a certain amount. -}
|
||||
damageBlocksBy :: Int -> Wall -> World -> World
|
||||
{-# INLINE damageBlocksBy #-}
|
||||
damageBlocksBy x wall w
|
||||
| isJust (wall ^? blHP) = foldr (\j -> walls . ix j . blHP -~ x) w (_blIDs wall)
|
||||
| otherwise = w
|
||||
|
||||
damageBlocksBy :: Int -> Wall -> World -> World
|
||||
damageBlocksBy x wl = case wl ^? wlBlockID of
|
||||
Just blid -> blocks . ix blid . blHPs %~ reduceHeadBy x
|
||||
Nothing -> id
|
||||
where
|
||||
reduceHeadBy y (z:zs) = z - y : zs
|
||||
reduceHeadBy _ [] = []
|
||||
|
||||
@@ -65,7 +65,7 @@ penWalls crEff wlEff ffEff pt hitThings w = case hitThings of
|
||||
[] -> ( w, mvPt)
|
||||
((p,E3x1 cr):_) -> (crEff pt p cr w, destroyAt p)
|
||||
((p,E3x3 ff):_) -> (ffEff pt p ff w, destroyAt p)
|
||||
((p,E3x2 wl):hs) | isJust (wl ^? blHP)
|
||||
((p,E3x2 wl):hs) | isJust (wl ^? wlBlockID)
|
||||
-> first (wlEff pt p wl) $ penWalls crEff wlEff ffEff pt hs w
|
||||
((p,E3x2 wl):_) | otherwise -> (wlEff pt p wl w, destroyAt p)
|
||||
where
|
||||
|
||||
@@ -5,8 +5,8 @@ module Dodge.WorldEvent.Shockwave
|
||||
where
|
||||
import Dodge.Data
|
||||
import Dodge.Data.DamageType
|
||||
import Dodge.WorldEvent.DamageBlock
|
||||
import Dodge.Creature.State.Data
|
||||
import Dodge.WorldEvent.DamageBlock
|
||||
import Dodge.Base
|
||||
import Dodge.Zone
|
||||
import Dodge.Picture.Layer
|
||||
|
||||
Reference in New Issue
Block a user