Cleanup
This commit is contained in:
+24
-21
@@ -34,8 +34,8 @@ andTest f g a = f a && g a
|
||||
onBoth :: (a -> b -> c) -> (d -> a) -> (d -> b) -> d -> c
|
||||
onBoth f g h x = f (g x) (h x)
|
||||
|
||||
crIsReloading :: (World, Creature) -> Bool
|
||||
crIsReloading (_,cr) = case cr ^? crInv . ix (_crInvSel cr) . itConsumption . reloadState . _Just' of
|
||||
crIsReloading :: Creature -> Bool
|
||||
crIsReloading cr = case cr ^? crInv . ix (_crInvSel cr) . itConsumption . reloadState . _Just' of
|
||||
Just t -> t > 0
|
||||
_ -> False
|
||||
|
||||
@@ -56,26 +56,23 @@ crCanSeeCID cid (w,cr) = hasLOS (_crPos cr) (_crPos $ _creatures w IM.! cid) w
|
||||
crCanSeeCIDR :: Int -> Creature -> Reader World Bool
|
||||
crCanSeeCIDR cid cr = reader $ \w -> hasLOS (_crPos cr) (_crPos $ _creatures w IM.! cid) w
|
||||
|
||||
crIsAiming :: (World,Creature) -> Bool
|
||||
crIsAiming (_,cr) = _posture (_crStance cr) == Aiming
|
||||
crIsAiming :: Creature -> Bool
|
||||
crIsAiming cr = _posture (_crStance cr) == Aiming
|
||||
|
||||
crIsAiming' :: Creature -> Bool
|
||||
crIsAiming' cr = _posture (_crStance cr) == Aiming
|
||||
|
||||
crIsAimingR :: Creature -> Reader World Bool
|
||||
crIsAimingR cr = return $ _posture (_crStance cr) == Aiming
|
||||
|
||||
crHasTarget :: (World,Creature) -> Bool
|
||||
crHasTarget (_,cr) = isJust $ cr ^? crIntention . targetCr . _Just
|
||||
|
||||
crHasTarget' :: Creature -> Bool
|
||||
crHasTarget' cr = isJust $ cr ^? crIntention . targetCr . _Just
|
||||
|
||||
crHasTargetR :: Creature -> Reader World Bool
|
||||
crHasTargetR cr = return $ isJust $ cr ^? crIntention . targetCr . _Just
|
||||
|
||||
crHasTargetLOS :: (World,Creature) -> Bool
|
||||
crHasTargetLOS (w,cr) = case cr ^? crIntention . targetCr . _Just of
|
||||
crHasTargetLOS :: World -> Creature -> Bool
|
||||
crHasTargetLOS w cr = case cr ^? crIntention . targetCr . _Just of
|
||||
Just i -> crCanSeeCr i (w,cr)
|
||||
Nothing -> False
|
||||
|
||||
crHasTargetLOS' :: World -> Creature -> Bool
|
||||
crHasTargetLOS' w cr = case cr ^? crIntention . targetCr . _Just of
|
||||
Just i -> crCanSeeCr i (w,cr)
|
||||
Nothing -> False
|
||||
|
||||
@@ -84,8 +81,8 @@ crHasTargetLOSR cr = reader $ \w -> case cr ^? crIntention . targetCr . _Just of
|
||||
Just i -> crCanSeeCr i (w,cr)
|
||||
Nothing -> False
|
||||
|
||||
crSafeDistFromTarg :: Float -> (World,Creature) -> Bool
|
||||
crSafeDistFromTarg d (_,cr) = case cr ^? crIntention . targetCr . _Just of
|
||||
crSafeDistFromTarg :: Float -> Creature -> Bool
|
||||
crSafeDistFromTarg d cr = case cr ^? crIntention . targetCr . _Just of
|
||||
Just tcr -> dist (_crPos cr) (_crPos tcr) > d
|
||||
Nothing -> True
|
||||
|
||||
@@ -103,8 +100,8 @@ crStratConMatches' strat cr = eqConstr strat (_crStrategy $ _crActionPlan cr)
|
||||
crStratConMatchesR :: Strategy -> Creature -> Reader World Bool
|
||||
crStratConMatchesR strat cr = return $ eqConstr strat (_crStrategy $ _crActionPlan cr)
|
||||
|
||||
crAwayFromPost :: (World,Creature) -> Bool
|
||||
crAwayFromPost (_,cr) = case find sentinelGoal $ _crGoal $ _crActionPlan cr of
|
||||
crAwayFromPost :: Creature -> Bool
|
||||
crAwayFromPost cr = case find sentinelGoal $ _crGoal $ _crActionPlan cr of
|
||||
Just (SentinelAt p _) -> dist p (_crPos cr) > 15
|
||||
_ -> False
|
||||
where
|
||||
@@ -119,8 +116,14 @@ crAwayFromPostR cr = return $ case find sentinelGoal $ _crGoal $ _crActionPlan c
|
||||
sentinelGoal (SentinelAt _ _) = True
|
||||
sentinelGoal _ = False
|
||||
|
||||
crHasAmmo :: (World,Creature) -> Bool
|
||||
crHasAmmo (_,cr) = maybe False (> 0) $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . ammoLoaded
|
||||
crHasAmmo :: Creature -> Bool
|
||||
crHasAmmo cr = maybe False (> 0) $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . ammoLoaded
|
||||
|
||||
crCanShoot :: (World,Creature) -> Bool
|
||||
crHasAmmo' :: Creature -> Bool
|
||||
crHasAmmo' cr = maybe False (> 0) $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . ammoLoaded
|
||||
|
||||
crCanShoot :: Creature -> Bool
|
||||
crCanShoot p = crIsAiming p && crHasAmmo p
|
||||
|
||||
crCanShoot' :: Creature -> Bool
|
||||
crCanShoot' p = crIsAiming' p && crHasAmmo' p
|
||||
|
||||
Reference in New Issue
Block a user