Generalise weapon character modes

This commit is contained in:
2021-04-29 23:13:41 +02:00
parent 6a38950501
commit 619756dd73
8 changed files with 129 additions and 127 deletions
+6 -16
View File
@@ -7,31 +7,21 @@ import Dodge.Data
import Dodge.Base
import Dodge.Item.Attachment.Data
import Data.Sequence
import Control.Lens
import Control.Monad
-- MODES SHOULD BE MADE UNIFORM
-- not sure if this is in the right place...
basicWeaponDisplay :: Item -> String
basicWeaponDisplay it = case it ^? itAttachment . _Just . itCharMode of
Just c -> midPadL 10 ' ' (_itName it) (' ' : aIfLoaded) ++ [' ',c]
otherwise -> midPadL 10 ' ' (_itName it) (' ' : aIfLoaded)
Just (c :<| _) -> midPadL 10 ' ' (_itName it) (' ' : aIfLoaded) ++ [' ',c]
_ -> 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"
0 -> show $ _wpLoadedAmmo it
x -> "R" ++ show x
displayLasGun :: Item -> String
displayLasGun it@(Weapon {_itAttachment = mayPhase})
+15 -1
View File
@@ -134,12 +134,26 @@ shootWithSound soundid f cid w
&& _wpFireState item == 0
&& _wpLoadedAmmo item > 0
reloadCondition = _wpLoadedAmmo item == 0
{- | Applies a world effect after a hammer position check. -}
hammerCheck
:: (Int -> World -> World) -- ^ Underlying effect
-> Int -- ^ Creature id
-> World
-> World
hammerCheck f cid w = case (_crInv cr IM.! _crInvSel cr) ^? itHammer of
Just HammerUp -> f cid $ setHammerDown w
_ -> setHammerDown w
where
cr = _creatures w IM.! cid
setHammerDown = creatures . ix cid . crInv . ix (_crInvSel cr) . itHammer .~ HammerDown
{- | Applies a world effect after an ammo check. -}
shoot
:: (Int -> World -> World)
-- ^ Underlying effect, takes creature id as input
-> Int -- ^ Creature id
-> World -> World
-> World
-> World
shoot f cid w
| fireCondition = over (pointerToItem . wpLoadedAmmo) (\ammo -> ammo-1)
$ set (pointerToItem . wpFireState) (_wpFireRate item)