Fold some ammo data into its own type

This commit is contained in:
2021-11-27 13:40:56 +00:00
parent bfdac2fad5
commit 92a8dd59b8
21 changed files with 175 additions and 115 deletions
+18 -10
View File
@@ -20,17 +20,19 @@ rewindGun :: Item
rewindGun = defaultGun
{ _itName = "REWINDER"
, _itIdentity = Rewinder
, _wpMaxAmmo = 0
, _wpLoadedAmmo = 0
, _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 0
, _wpLoadedAmmo = 0
}
, _itEffect = ItRewindEffect rewindEffect []
, _itUse = LeftUse $ \cr invid -> useRewindGun (_crInv cr IM.! invid) cr
}
rewindEffect :: ItEffect -> Creature -> Int -> World -> World
rewindEffect _ cr invid w
| Just invid == _crLeftInvSel cr = w & rewindWorlds %~ (take 250 . (w' : ))
& creatures . ix (_crID cr) . crInv . ix invid . wpLoadedAmmo .~ length (_rewindWorlds w)
& creatures . ix (_crID cr) . crInv . ix invid . wpAmmo . wpLoadedAmmo .~ length (_rewindWorlds w)
| otherwise = w & rewindWorlds .~ []
& creatures . ix (_crID cr) . crInv . ix invid . wpLoadedAmmo .~ 0
& creatures . ix (_crID cr) . crInv . ix invid . wpAmmo . wpLoadedAmmo .~ 0
where
w' = w & rewindWorlds .~ []
& rewinding .~ True
@@ -52,8 +54,10 @@ shrinkGun :: Item
shrinkGun = defaultGun
{ _itName = "SHRINKER"
, _itIdentity = Generic
, _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
, _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
}
, _wpReloadTime = 20
, _wpReloadState = 0
, _itUseRate = 0
@@ -90,8 +94,10 @@ blinkGun :: Item
blinkGun = defaultGun
{ _itName = "BLINKER"
, _itIdentity = Blinker
, _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
, _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
}
, _wpReloadTime = 20
, _wpReloadState = 0
, _itUseRate = 0
@@ -129,8 +135,10 @@ forceFieldGun :: Item
forceFieldGun = defaultGun
{ _itName = "FORCEFIELD"
, _itIdentity = ForceFieldGun
, _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
, _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 100
, _wpLoadedAmmo = 100
}
, _wpReloadTime = 40
, _wpReloadState = 0
, _itUseRate = 10