Work towards adding external ammo sources

This commit is contained in:
2023-05-17 11:01:52 +01:00
parent 63c71c852d
commit 7df81559d9
30 changed files with 246 additions and 196 deletions
+19 -12
View File
@@ -53,7 +53,7 @@ selectedItemDisplay cr it = itemDisplayWithNumber (showSelectedConsumption cr (_
-- | Displays the item name, ammo if loaded, and any selected '_itCharMode'.
showSelectedConsumption :: Creature -> ItemUse -> String
showSelectedConsumption cr iu = case iu of
HeldUse{} -> showReloadProgress cr (_heldConsumption iu)
HeldUse{} -> showReloadProgress cr (iu ^?! heldConsumption . laSource)
LeftUse{} -> showAutoRechargeProgress (_leftConsumption iu)
EquipUse{} -> ""
_ -> show $ iu ^?! useAmount . getItAmount -- partial, be careful if adding new data constructors
@@ -65,12 +65,14 @@ showAutoRechargeProgress lc = case lc of
| otherwise -> show (_arLoaded lc)
ChargeableAmmo{} -> show (_wpCharge lc)
showReloadProgress :: Creature -> HeldConsumption -> String
showReloadProgress :: Creature -> AmmoSource -> String
showReloadProgress cr ic = case cr ^? crManipulation . manObject . inInventory . iselAction of
Just (ReloadAction i la) -> show i ++ showLoadActionType la (_laLoaded ic)
_ -> case ic ^? laProgress . _Just . ix 0 of
Nothing -> show $ _laLoaded ic
Just la -> show (_actionTime la) ++ showLoadActionType la (_laLoaded ic)
Just (ReloadAction i la) -> show i ++ showLoadActionType la ic
_ -> case ic of
InternalSource ia -> case ia ^? iaProgress . _Just . ix 0 of
Nothing -> show $ ia ^. iaLoaded
Just la -> show (_actionTime la) ++ showLoadActionType la ic
_ -> "X"
showConsumption :: ItemUse -> String
showConsumption iu = case iu of
@@ -85,16 +87,21 @@ showEUseNumber ee = case _eeUse ee of
_ -> ""
showReloadProgress' :: HeldConsumption -> String
showReloadProgress' ic = case ic ^? laProgress . _Just . ix 0 of
Nothing -> show $ _laLoaded ic
Just la -> show (_actionTime la) ++ showLoadActionType la (_laLoaded ic)
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)
showLoadActionType :: LoadAction -> Int -> String
showLoadActionType la x = case la of
showLoadActionType :: LoadAction -> AmmoSource -> String
showLoadActionType la as = case la of
LoadEject{} -> "E"
LoadInsert{} -> "L"
LoadAdd{} -> "A" ++ show x
LoadAdd{} -> "A" ++ x
LoadPrime{} -> "P"
where
x = maybe "" show $ as ^? _InternalSource . iaLoaded
maybeWarmupStatus :: Item -> Maybe String
maybeWarmupStatus it = case it ^? itUse . heldDelay . warmMax of