Remove consumable records

This commit is contained in:
2025-06-05 21:15:20 +01:00
parent 816ab4222f
commit 10ca82c4d5
16 changed files with 258 additions and 321 deletions
+10 -12
View File
@@ -3,6 +3,7 @@ module Dodge.Creature.State (
doDamage,
) where
import Dodge.Item.MaxAmmo
import Control.Applicative
import Dodge.HeldUse
import Control.Monad
@@ -208,7 +209,7 @@ trySynthBullet loc w = fromMaybe w $ do
then do
bat <- loc ^? locLDT . ldtLeft . ix 0 . _2 . ldtValue . _1
j <- bat ^? itLocation . ilInvID
y <- bat ^? itConsumables . magLoadStatus . iaLoaded
y <- bat ^. itConsumables
guard $ y > 0
return $
w
@@ -225,14 +226,13 @@ trySynthBullet loc w = fromMaybe w $ do
. crInv
. ix j
. itConsumables
. magLoadStatus
. iaLoaded
. _Just
-~ 1
else do
mag <- loc ^? locLdtContext . cldtParent . _1
j <- mag ^? itLocation . ilInvID
y <- mag ^? itConsumables . magLoadStatus . iaLoaded
ymax <- mag ^? itConsumables . magLoadStatus . iaMax
y <- mag ^. itConsumables
ymax <- maxAmmo mag-- ^? itConsumables . magLoadStatus . iaMax
guard $ y < ymax
return $
w
@@ -249,8 +249,7 @@ trySynthBullet loc w = fromMaybe w $ do
. crInv
. ix j
. itConsumables
. magLoadStatus
. iaLoaded
. _Just
+~ 1
where
itm = loc ^. locLDT . ldtValue . _1
@@ -314,7 +313,7 @@ shineTargetLaser ::
shineTargetLaser cr itmtree (p, q) w = fromMaybe (w & pointittarg . itTgPos .~ Nothing) $ do
guard (crIsAiming cr)
(_, mag) <- find (isammolink . _iatType . fst) (itmtree ^. ldtLeft)
i <- mag ^? ldtValue . _1 . itConsumables . magLoadStatus . iaLoaded
i <- mag ^. ldtValue . _1 . itConsumables
guard $ i >= x
maginvid <- mag ^? ldtValue . _1 . itLocation . ilInvID
return $
@@ -324,8 +323,7 @@ shineTargetLaser cr itmtree (p, q) w = fromMaybe (w & pointittarg . itTgPos .~ N
. crInv
. ix maginvid
. itConsumables
. magLoadStatus
. iaLoaded
. _Just
-~ x
& cWorld . lWorld . lasers
.:~ Laser
@@ -355,14 +353,14 @@ shineTorch ::
World
shineTorch cr itmtree (p, q) = fromMaybe id $ do
(_, mag) <- find (isammolink . _iatType . fst) (itmtree ^. ldtLeft)
i <- mag ^? ldtValue . _1 . itConsumables . magLoadStatus . iaLoaded
i <- mag ^. ldtValue . _1 . itConsumables
guard $ crIsAiming cr
guard $ i >= x
invid <- mag ^? ldtValue . _1 . itLocation . ilInvID
return $
--(cWorld . lWorld . tempLightSources .:~ tlsTimeRadColPos 1 250 0.7 pos'')
(cWorld . lWorld . lights .:~ LSParam pos'' 250 0.7)
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itConsumables . magLoadStatus . iaLoaded -~ x)
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itConsumables . _Just -~ x)
where
x = 10
isammolink AmmoInLink{} = True