Continue to refactor item datatypes, add a shape to rockets

This commit is contained in:
2021-11-27 22:05:12 +00:00
parent 652af6b0a9
commit fe02739621
15 changed files with 135 additions and 78 deletions
+27 -4
View File
@@ -7,6 +7,7 @@ module Dodge.Item.Weapon.InventoryDisplay
import Dodge.Data
import Padding
import Data.Maybe
import Data.Sequence
import Control.Lens
{- | Displays the item name, ammo if loaded, and any selected '_itCharMode'. -}
@@ -20,7 +21,29 @@ basicWeaponDisplay it = midPadL 10 ' ' thename (' ' : thenumber) ++ theparam
x -> "R" ++ show x
Just am@ChargeableAmmo{} -> show $ _wpCharge am
Nothing -> ""
theparam = case it ^? itAttachment of
Just ItCharMode {_itCharMode = (c :<| _)} -> [' ',c]
Just ItMode {_itMode = i} -> show i
_ -> []
theparam = fromMaybe []
. listToMaybe
$ mapMaybe ($ it)
[ maybeModeStatus
, maybeWarmupStatus
, maybeRateStatus
]
maybeModeStatus :: Item -> Maybe String
maybeModeStatus it = case it ^? itAttachment of
Just ItCharMode {_itCharMode = (c :<| _)} -> Just [' ',c]
Just ItMode {_itMode = i} -> Just $ show i
_ -> Nothing
maybeRateStatus :: Item -> Maybe String
maybeRateStatus it = case it ^? itUse . useDelay . rateMaxMax of
Nothing -> Nothing
_ -> Just $ ' ' : "T" ++ leftPad 3 ' ' (show (_rateMax . _useDelay $ _itUse it))
maybeWarmupStatus :: Item -> Maybe String
maybeWarmupStatus it = case it ^? itUse . useDelay . warmMax of
Nothing -> Nothing
Just m -> case m - (_warmTime . _useDelay $ _itUse it) of
x | x <= 1 -> Just " WARM"
| otherwise -> let n = show x
in Just $ ' ' : Prelude.take (4 - Prelude.length n) "WARM" ++ n