Commit before implementing positional inventory

This commit is contained in:
2023-05-18 09:52:46 +01:00
parent 7df81559d9
commit 2f0bb5115b
12 changed files with 132 additions and 78 deletions
+21 -11
View File
@@ -5,6 +5,7 @@ module Dodge.Item.Display (
itemBaseName,
) where
import Dodge.Item.Info
import Data.Maybe
import Data.Sequence
import Dodge.Data.Creature
@@ -55,7 +56,7 @@ showSelectedConsumption :: Creature -> ItemUse -> String
showSelectedConsumption cr iu = case iu of
HeldUse{} -> showReloadProgress cr (iu ^?! heldConsumption . laSource)
LeftUse{} -> showAutoRechargeProgress (_leftConsumption iu)
EquipUse{} -> ""
EquipUse{_equipEffect = ee} -> showEquipmentNumber ee
_ -> show $ iu ^?! useAmount . getItAmount -- partial, be careful if adding new data constructors
showAutoRechargeProgress :: LeftConsumption -> String
@@ -72,26 +73,36 @@ showReloadProgress cr ic = case cr ^? crManipulation . manObject . inInventory .
InternalSource ia -> case ia ^? iaProgress . _Just . ix 0 of
Nothing -> show $ ia ^. iaLoaded
Just la -> show (_actionTime la) ++ showLoadActionType la ic
_ -> "X"
ExternalSource ea -> fromMaybe "X" $ do
i <- ea ^? _Just
itm <- cr ^? crInv . ix i
return $ show $ itemBaseName itm
showConsumption :: ItemUse -> String
showConsumption iu = case iu of
HeldUse{} -> showReloadProgress' (_heldConsumption iu)
LeftUse{} -> showAutoRechargeProgress (_leftConsumption iu)
EquipUse {_equipEffect = ee} -> showEUseNumber ee
EquipUse{_equipEffect = ee} -> showEquipmentNumber ee
_ -> show $ iu ^?! useAmount . getItAmount
showEUseNumber :: EquipEffect -> String
showEUseNumber ee = case _eeUse ee of
showEquipmentNumber :: EquipEffect -> String
showEquipmentNumber ee = case _eeUse ee of
EFuelSource x _ -> show x
EAmmoSource {_euseAmmoAmount = x} -> showIntKMG' x
EBatterySource {_euseBatteryAmount = x} -> show x
_ -> ""
showReloadProgress' :: HeldConsumption -> String
showReloadProgress' ic = case ic ^? laSource . _InternalSource . iaProgress . _Just . ix 0 of
Nothing -> fromMaybe "X" $ do
x <- ic ^? laSource . _InternalSource . iaLoaded
return $ show x
Just la -> show (_actionTime la) ++ showLoadActionType la (_laSource ic)
showReloadProgress' ic = case ic ^? laSource of
Just (InternalSource ia) -> case ia ^? iaProgress . _Just . ix 0 of
Nothing -> fromMaybe "" $ do
x <- ic ^? laSource . _InternalSource . iaLoaded
return $ show x
Just la -> show (_actionTime la) ++ showLoadActionType la (_laSource ic)
Just (ExternalSource ea) -> fromMaybe "X" $ do
i <- ea ^? _Just
return $ show i
_ -> ""
showLoadActionType :: LoadAction -> AmmoSource -> String
showLoadActionType la as = case la of
@@ -101,7 +112,6 @@ showLoadActionType la as = case la of
LoadPrime{} -> "P"
where
x = maybe "" show $ as ^? _InternalSource . iaLoaded
maybeWarmupStatus :: Item -> Maybe String
maybeWarmupStatus it = case it ^? itUse . heldDelay . warmMax of