module Dodge.Wall.Delete
    ( deleteWallIDs
    , deleteWallID
    ) where
import Dodge.Data
import Dodge.Wall.Zone

import Control.Lens
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS

deleteWallID :: Int -> World -> World
deleteWallID i w = w & walls %~ IM.delete i
    & deleteWallFromZones wl
  where
    wl = _walls w IM.! i

deleteWall :: Wall -> World -> World
deleteWall wl = (walls %~ IM.delete i)
    . deleteWallFromZones wl
  where
    i = _wlID wl

deleteWallIDs :: IS.IntSet -> World -> World
deleteWallIDs is w = foldr deleteWall w $ IM.restrictKeys (_walls w) is
