Partially refactor ammo extraction, work on pulse rifle
This commit is contained in:
+24
-34
@@ -153,6 +153,7 @@ invRootItemEffs cr =
|
||||
invItemLocUpdate :: Creature -> LocationDT OItem -> World -> World
|
||||
invItemLocUpdate cr loc w = doAnyEquipmentEffect loc cr $ case itm ^. itType of
|
||||
ATTACH BULLETSYNTH -> trySynthBullet loc w
|
||||
ATTACH CAPACITOR -> tryDrawToCapacitor loc w
|
||||
EQUIP WRIST_ECG | haspulse -> tryUseParent loc w
|
||||
COPIER _ -> copierItemUpdate itm cr w
|
||||
HELD FLATSHIELD -> rootNotrootEff createShieldWall removeShieldWall itm cr w
|
||||
@@ -229,6 +230,22 @@ tryUseParent loc w = fromMaybe w $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
return $ gadgetEffect InitialPress t cr w
|
||||
|
||||
tryDrawToCapacitor :: LocationDT OItem -> World -> World
|
||||
tryDrawToCapacitor loc w = fromMaybe w $ do
|
||||
itm <- loc ^? locDT . dtValue . _1
|
||||
i <- itm ^? itLocation . ilInvID
|
||||
x <- loc ^? locDT . dtValue . _1 . itConsumables . _Just
|
||||
guard $ x < 250
|
||||
bat <- loc ^? locDT . dtLeft . ix 0 . dtValue . _1
|
||||
j <- bat ^? itLocation . ilInvID
|
||||
y <- bat ^? itConsumables . _Just
|
||||
let z = min y 10
|
||||
return $ w
|
||||
& invpoint . ix i . itConsumables . _Just +~ z
|
||||
& invpoint . ix j . itConsumables . _Just -~ z
|
||||
where
|
||||
invpoint = cWorld . lWorld . creatures . ix 0 . crInv
|
||||
|
||||
trySynthBullet :: LocationDT OItem -> World -> World
|
||||
trySynthBullet loc w = fromMaybe w $ do
|
||||
i <- itm ^? itLocation . ilInvID
|
||||
@@ -239,48 +256,21 @@ trySynthBullet loc w = fromMaybe w $ do
|
||||
j <- bat ^? itLocation . ilInvID
|
||||
y <- bat ^. itConsumables
|
||||
guard $ y > 0
|
||||
return $
|
||||
w
|
||||
& cWorld . lWorld . creatures
|
||||
. ix 0
|
||||
. crInv
|
||||
. ix i
|
||||
. itUse
|
||||
. uaParams
|
||||
. apInt
|
||||
+~ 1
|
||||
& cWorld . lWorld . creatures
|
||||
. ix 0
|
||||
. crInv
|
||||
. ix j
|
||||
. itConsumables
|
||||
. _Just
|
||||
-~ 1
|
||||
return $ w
|
||||
& invpoint . ix i . itUse . uaParams . apInt +~ 1
|
||||
& invpoint . ix j . itConsumables . _Just -~ 1
|
||||
else do
|
||||
mag <- loc ^? locDtContext . cdtParent . _1
|
||||
j <- mag ^? itLocation . ilInvID
|
||||
y <- mag ^. itConsumables
|
||||
ymax <- maxAmmo mag
|
||||
guard $ y < ymax
|
||||
return $
|
||||
w
|
||||
& cWorld . lWorld . creatures
|
||||
. ix 0
|
||||
. crInv
|
||||
. ix i
|
||||
. itUse
|
||||
. uaParams
|
||||
. apInt
|
||||
.~ 0
|
||||
& cWorld . lWorld . creatures
|
||||
. ix 0
|
||||
. crInv
|
||||
. ix j
|
||||
. itConsumables
|
||||
. _Just
|
||||
+~ 1
|
||||
return $ w
|
||||
& invpoint . ix i . itUse . uaParams . apInt .~ 0
|
||||
& invpoint . ix j . itConsumables . _Just +~ 1
|
||||
where
|
||||
itm = loc ^. locDT . dtValue . _1
|
||||
invpoint = cWorld . lWorld . creatures . ix 0 . crInv
|
||||
|
||||
drawARHUD :: LocationDT OItem -> World -> World
|
||||
drawARHUD (LocDT con _) w = fromMaybe w $ do
|
||||
|
||||
Reference in New Issue
Block a user