Files
loop/src/Dodge/Item/Weapon/FractionLoaded.hs
T
2022-07-27 12:49:23 +01:00

23 lines
720 B
Haskell

module Dodge.Item.Weapon.FractionLoaded
( fractionLoadedAmmo
, fractionLoadedAmmo2
) where
import Dodge.Data
---- this shouldn't really be used
loadedAmmo :: Item -> Int
loadedAmmo = _laLoaded . _heldConsumption . _itUse
-- | _laTransfer (_itConsumption it) == NoTransfer = _laLoaded (_itConsumption it)
-- | otherwise = 0
fractionLoadedAmmo :: Item -> Float
fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral (itmaxammo it)
where
itmaxammo = _laMax . _heldConsumption . _itUse
fractionLoadedAmmo2 :: Item -> Float
fractionLoadedAmmo2 it = 1 -
(1 - fromIntegral (loadedAmmo it) / fromIntegral (itMaxAmmo it))**2
where
itMaxAmmo = _laMax . _heldConsumption . _itUse