Modularise code concerning items

This commit is contained in:
2021-03-12 02:29:24 +01:00
parent 9bdc6fddd7
commit 22275beb89
9 changed files with 339 additions and 292 deletions
+34
View File
@@ -0,0 +1,34 @@
module Dodge.Item.Weapon.InventoryDisplay
where
import Dodge.Data
import Dodge.Base
basicWeaponDisplay :: Item -> String
basicWeaponDisplay it = midPadL 10 ' ' (_itName it) (' ' : aIfLoaded)
where
availableAmmo = show $ _wpMaxAmmo it
aIfLoaded = case (_wpReloadState it) of
0 -> show $ _wpLoadedAmmo it
x -> "R" ++ show x
displayAutoGun :: Item -> String
displayAutoGun it@(Weapon {_itAttachment = mayMode})
= midPadL 10 ' ' "AUTOGUN" (' ':aIfLoaded) ++ (' ':phaseS)
where aIfLoaded = case (_wpReloadState it) of
0 -> show $ _wpLoadedAmmo it
x -> "R" ++ show x
phaseS = case mayMode of
Just (ItMode 0) -> "M"
Just (ItMode 1) -> "S"
Just (ItMode 2) -> "B"
displayLasGun :: Item -> String
displayLasGun it@(Weapon {_itAttachment = mayPhase})
= midPadL 10 ' ' "LASER" (' ':aIfLoaded) ++ (' ':phaseS)
where aIfLoaded = case (_wpReloadState it) of
0 -> show $ _wpLoadedAmmo it
x -> "R" ++ show x
phaseS = case mayPhase of
Just (ItPhaseV 0.2) -> "V"
Just (ItPhaseV 1) -> "/"
Just (ItPhaseV 5) -> "Z"