Rethink item ammo to item consumables, start item type datatype

This commit is contained in:
2021-11-29 16:22:31 +00:00
parent 3a605b8156
commit f40d486d68
31 changed files with 238 additions and 193 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) . wpAmmo . wpReloadState of
crIsReloading (_,cr) = case cr ^? crInv . ix (_crInvSel cr) . itConsumption . wpReloadState of
Just t -> t > 0
_ -> False
crIsReloadingR :: Creature -> Reader World Bool
crIsReloadingR cr = return $ case cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpReloadState of
crIsReloadingR cr = return $ case cr ^? crInv . ix (_crInvSel cr) . itConsumption . wpReloadState 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) . wpAmmo . wpLoadedAmmo
crHasAmmo (_,cr) = maybe False (> 0) $ cr ^? crInv . ix (_crInvSel cr) . itConsumption . wpLoadedAmmo
crCanShoot :: (World,Creature) -> Bool
crCanShoot p = crIsAiming p && crHasAmmo p