Make item display universal
This commit is contained in:
@@ -1,21 +1,10 @@
|
||||
module Dodge.Default.Item
|
||||
( basicItemDisplay
|
||||
, maybeWarmupStatus
|
||||
, maybeRateStatus
|
||||
, moduleStrings
|
||||
, defaultItem
|
||||
( defaultItem
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Padding
|
||||
import Dodge.Inventory.ItemSpace
|
||||
import Dodge.Module
|
||||
import Picture
|
||||
import Shape
|
||||
|
||||
import Data.Maybe
|
||||
import Data.Sequence
|
||||
import Control.Lens
|
||||
|
||||
defaultItem :: Item
|
||||
defaultItem = Item
|
||||
{ _itCurseStatus = Uncursed
|
||||
@@ -25,7 +14,6 @@ defaultItem = Item
|
||||
, _itID = Nothing
|
||||
, _itIsHeld = False
|
||||
, _itInvColor = yellow
|
||||
, _itInvDisplay = basicItemDisplay
|
||||
, _itInvSize = 1
|
||||
, _itInvPos = Nothing
|
||||
, _itDimension = ItemDimension 0 0 NoPortage (const mempty)
|
||||
@@ -39,51 +27,5 @@ defaultItem = Item
|
||||
, _itValue = ItemValue 0 MundaneItem
|
||||
}
|
||||
|
||||
{- | Displays the item name, ammo if loaded, and any selected '_itCharMode'. -}
|
||||
-- TODO make work on remote launchers
|
||||
basicItemDisplay :: Item -> [String]
|
||||
basicItemDisplay 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
|
||||
]
|
||||
-- this can be moved to Dodge/Module and unified with moduleSizes
|
||||
|
||||
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))
|
||||
|
||||
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
|
||||
|
||||
defaultItemType :: ItemType
|
||||
defaultItemType = ItemType NOTDEFINED mempty NoStack
|
||||
|
||||
|
||||
@@ -107,7 +107,6 @@ defaultGun = defaultItem
|
||||
, _itInvPos = Nothing
|
||||
, _itIsHeld = False
|
||||
, _itEffect = NoItEffect
|
||||
, _itInvDisplay = basicItemDisplay
|
||||
, _itInvColor = white
|
||||
, _itInvSize = 1
|
||||
, _itParams = NoParams
|
||||
|
||||
Reference in New Issue
Block a user