Make item display universal

This commit is contained in:
2022-06-19 12:56:30 +01:00
parent df1f3ad6b0
commit 541a04f1bc
22 changed files with 349 additions and 358 deletions
+60
View File
@@ -0,0 +1,60 @@
module Dodge.Item.Display where
import Dodge.Module
import Dodge.Data
import Dodge.Inventory.ItemSpace
import Padding
import LensHelp
import Data.Maybe
import Data.Sequence
itemString :: Item -> String
itemString = head . itemDisplay
{- | Displays the item name, ammo if loaded, and any selected '_itCharMode'. -}
-- TODO make work on remote launchers
itemDisplay :: Item -> [String]
itemDisplay it = Prelude.take (itSlotsTaken it) $
(midPadL 15 ' ' thename (' ' : thenumber) ++ theparam)
: catMaybes [maybeWarmupStatus it]
++ moduleStrings it ++ repeat "*"
where
thename = show . _iyBase $ _itType it
thenumber = case it ^? itConsumption of
Just am@LoadableAmmo{} -> case _laReloadState am of
Nothing' -> show (_laLoaded am)
Just' x -> show x ++ "R" ++ show (_laLoaded am)
Just am@ChargeableAmmo{} -> show $ _wpCharge am
Just x@ItemItselfConsumable{} -> show (_icAmount x)
Just NoConsumption -> ""
Nothing -> ""
theparam = fromMaybe []
. listToMaybe
$ mapMaybe ($ it)
[ maybeModeStatus
-- , maybeWarmupStatus
-- , maybeRateStatus
]
-- & itInvDisplay .~ \it -> head (basicItemDisplay it) :
-- ["*FIRERATE:" ++ fromMaybe "" (maybeRateStatus 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 (5 - Prelude.length n) "*WARM" ++ n
maybeModeStatus :: Item -> Maybe String
maybeModeStatus it = case it ^? itAttachment of
Just AttachCharMode {_atCharMode = (c :<| _)} -> Just [' ',c]
Just AttachMode {_atMode = i} -> Just $ show i
_ -> Nothing
maybeRateStatus :: Item -> Maybe String
maybeRateStatus it = case it ^? itUse . useDelay . rateMaxMax of
Nothing -> Nothing
_ -> Just $ leftPad 3 ' ' (show (_rateMax . _useDelay $ _itUse it))
-4
View File
@@ -139,10 +139,6 @@ flatShield = defaultEquipment
, _heldScroll = \_ _ -> id
}
, _itInvSize = 3
, _itInvDisplay = \it -> head (basicItemDisplay it) :
["*" ++ replicate 13 ' ' ++ "*"
,"*" ++ replicate 13 ' ' ++ "*"
]
}
& itType . iyBase .~ FLATSHIELD
flatShieldEquipSPic :: Item -> SPic
-5
View File
@@ -7,7 +7,6 @@ module Dodge.Item.Weapon.BulletGun.Rod
, machineGun
) where
import Dodge.Data
import Dodge.Default.Item
import Dodge.Item.Weapon.BulletGun.Clip
import Dodge.Particle.HitEffect
import Dodge.Particle.Damage
@@ -33,7 +32,6 @@ import Shape
--import Sound.Data
import LensHelp
import Data.Maybe
--import qualified Data.Sequence as Seq
--import Control.Lens
--import Control.Monad.State
@@ -150,6 +148,3 @@ machineGun = bangRod
& itConsumption . laReloadTime .~ 75
& itInvSize .~ 3
& itParams. torqueAfter .~ 0.2 -- not sure if this is necessary?
& itInvDisplay .~ \it -> head (basicItemDisplay it) :
["*FIRERATE:" ++ fromMaybe "" (maybeRateStatus it)
]
+1
View File
@@ -16,6 +16,7 @@ module Dodge.Item.Weapon.ExtraEffect
) where
import Dodge.Data
import Dodge.Base
import Dodge.Zone
import Dodge.SoundLogic
--import Dodge.Item.Weapon.Decoration
import Dodge.Item.Weapon.UseEffect