module Dodge.Creature.ArmourChase
    ( armourChaseCrit
    , flockArmourChaseCrit
    ) where
import Dodge.Data
import Dodge.Default
--import Dodge.Creature.State
import Dodge.Creature.Update
import Dodge.Creature.ChaseCrit
--import Dodge.Creature.ChainUpdates
import Dodge.Creature.ReaderUpdate
import Dodge.Creature.Perception
import Dodge.Creature.Picture
--import Dodge.Creature.Impulse
import Dodge.Creature.Action
import Dodge.Item.Equipment
import Dodge.Item.Consumable
--import Picture

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

flockArmourChaseCrit :: Creature
flockArmourChaseCrit = defaultCreature
    { _crUpdate = defaultImpulsive
        [ watchUpdateStrat [] 
        , const doStrategyActions
        , performActions
        , targetYouWhenCognizant
        , setTargetMv (\_ -> _targetCr . _crIntention)
        , flockACC
        , perceptionUpdate [0]
        , goToTarget
        , const overrideMeleeCloseTarget
        , const (crMeleeCooldown %~ max 0 . subtract 1)
        ]
    , _crName = "armourChaseCrit"
    , _crHP = 300
    , _crPict = basicCrPict
    , _crInv = IM.fromList 
        [(0,frontArmour)
        ,(1,medkit 200)
        ]
    , _crActionPlan = ActionPlan
        {_apImpulse     = []
        ,_apAction      = []
        ,_apStrategy    = FollowImpulses
        ,_apGoal        = [Kill 0]
        }
    , _crMeleeCooldown = 0
    , _crGroup = ShieldGroup
    , _crMvType = defaultChaseMvType
    }  
armourChaseCrit :: Creature
armourChaseCrit = chaseCrit
    { _crName = "armourChaseCrit"
    --, _crUpdate = defaultImpulsive []
    , _crInv = IM.fromList 
        [(0,frontArmour)
        ,(1,medkit 200)
        ]
    , _crMvType = defaultChaseMvType {_mvTurnRad = f}
    } 
    & crEquipment . at OnChest ?~ 0
    & crInvEquipped . at 0 ?~ OnChest
  where
    f _ = 0.05
