Allow for partial reloading

This commit is contained in:
2021-12-01 17:40:09 +00:00
parent d75ea2b252
commit 016a1faf80
21 changed files with 181 additions and 143 deletions
+3 -3
View File
@@ -35,12 +35,12 @@ 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 . wpReloadState of
crIsReloading (_,cr) = case cr ^? crInv . ix (_crInvSel cr) . itConsumption . reloadState . _Just' of
Just t -> t > 0
_ -> False
crIsReloadingR :: Creature -> Reader World Bool
crIsReloadingR cr = return $ case cr ^? crInv . ix (_crInvSel cr) . itConsumption . wpReloadState of
crIsReloadingR cr = return $ case cr ^? crInv . ix (_crInvSel cr) . itConsumption . reloadState . _Just' of
Just t -> t > 0
_ -> False
@@ -114,7 +114,7 @@ crAwayFromPostR cr = return $ case find sentinelGoal $ _crGoal $ _crActionPlan c
sentinelGoal _ = False
crHasAmmo :: (World,Creature) -> Bool
crHasAmmo (_,cr) = maybe False (> 0) $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . wpLoadedAmmo
crHasAmmo (_,cr) = maybe False (> 0) $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . ammoLoaded
crCanShoot :: (World,Creature) -> Bool
crCanShoot p = crIsAiming p && crHasAmmo p