Files
loop/src/Dodge/WorldBool.hs
T

23 lines
767 B
Haskell

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