Move equipment effects into "zipper" item update
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user