Move equipment effects into "zipper" item update

This commit is contained in:
2024-12-19 10:00:39 +00:00
parent 19e5927934
commit 3ffe61e6db
5 changed files with 15 additions and 8 deletions
+11 -4
View File
@@ -70,7 +70,7 @@ crUpdate f =
, updateInv -- upInv must be called before invSideEff 22.05.23
, invRootItemEffs
, invSideEff
, equipmentEffects
-- , equipmentEffects
]
checkDeath :: Creature -> World -> World
@@ -172,11 +172,11 @@ invRootItemEffs :: Creature -> World -> World
invRootItemEffs cr =
appEndo $
foldMap
(reduceLocLDT (Endo . invItemLocUpdate) . LocLDT TopLDT)
(reduceLocLDT (Endo . invItemLocUpdate cr) . LocLDT TopLDT)
(invLDT (_crInv cr))
invItemLocUpdate :: LocationLDT ItemLink ComposedItem -> World -> World
invItemLocUpdate loc w = case itm ^. itType of
invItemLocUpdate :: Creature -> LocationLDT ItemLink ComposedItem -> World -> World
invItemLocUpdate cr loc w = doAnyEquipmentEffect cr loc $ case itm ^. itType of
ATTACH BULLETSYNTH -> trySynthBullet loc w
EQUIP WRIST_ECG | haspulse -> tryUseParent loc w
_ -> w
@@ -186,6 +186,13 @@ invItemLocUpdate loc w = case itm ^. itType of
== Just 0
itm = loc ^. locLDT . ldtValue . _1
doAnyEquipmentEffect :: Creature -> LocationLDT ItemLink ComposedItem -> World -> World
doAnyEquipmentEffect cr loc = case itm ^? itLocation . ilEquipPosition . _Just of
Just _ -> useE (_eeUse (_uequipEffect $ _itUse itm)) itm cr
_ -> id
where
itm = loc ^. locLDT . ldtValue . _1
tryUseParent :: LocationLDT ItemLink ComposedItem -> World -> World
tryUseParent loc w = fromMaybe w $ do
t <- locUp loc