Files
loop/src/Dodge/Creature/SetTarget.hs
T
2021-09-09 13:29:09 +01:00

20 lines
594 B
Haskell

{- |
Deals with setting a target for creatures
-}
module Dodge.Creature.SetTarget
where
import Dodge.Data
import Dodge.Creature.Perception.Data
import Control.Lens
import qualified Data.IntMap.Strict as IM
{- | Assumes that you are id 0: if creature is cognizant of you, sets you as target -}
targetYouWhenCognizant
:: World
-> Creature
-> Creature
targetYouWhenCognizant w cr = case cr ^? crPerception . crAwarenessLevel . ix 0 of
Just (Cognizant _) -> cr & crIntention . targetCr ?~ _creatures w IM.! 0
_ -> cr & crIntention . targetCr .~ Nothing