module Dodge.WorldBool where import Control.Lens import Data.Maybe import Dodge.Creature.Test import Dodge.CreatureEffect import Dodge.Data.World import qualified IntMapHelp as IM doWdBl :: WdBl -> World -> Bool doWdBl wb w = case wb of WdBlConst bl -> bl WdTrig i -> fromMaybe False $ w ^? cWorld . lWorld . triggers . ix i WdBlDoorMoving i -> fromMaybe False $ do dr <- w ^? cWorld . lWorld . doors . ix i return (DoorHalfway == _drStatus dr) WdBlCrFilterNearPoint r p t -> any (crNearPoint r p) (IM.filter (doCrBl t) (w ^. cWorld . lWorld . creatures)) WdBlBtOn btid -> w ^?! cWorld . lWorld . buttons . ix btid . btEvent . btOn -- unsafe WdBlNegate x -> not $ doWdBl x w