Make equipment effects use item locations
Move towards removing on/off equipment effects
This commit is contained in:
@@ -72,6 +72,8 @@ crUpdate f =
|
||||
, invSideEff
|
||||
-- , equipmentEffects
|
||||
]
|
||||
-- I have changed the ordering of item/equipment effects, which may have
|
||||
-- unforseen consequences, be aware
|
||||
|
||||
checkDeath :: Creature -> World -> World
|
||||
checkDeath cr w
|
||||
@@ -146,21 +148,10 @@ applyPastDamages cr w
|
||||
& randGen .~ g
|
||||
| otherwise = w
|
||||
|
||||
useEquipment :: Creature -> Int -> World -> World
|
||||
useEquipment cr i = useE (_eeUse (_uequipEffect $ _itUse itm)) itm cr
|
||||
where
|
||||
itm = _crInv cr IM.! i
|
||||
|
||||
-- a map updating all inventory items
|
||||
updateInv :: Creature -> World -> World
|
||||
updateInv cr = cWorld . lWorld . creatures . ix (_crID cr) . crInv %~ IM.map itemUpdate
|
||||
|
||||
-- a loop going over equipped items
|
||||
-- maybe this should be done during a different loop (invSideEff)?
|
||||
equipmentEffects :: Creature -> World -> World
|
||||
--equipmentEffects cr = flip (foldl' $ flip $ useEquipment cr) (IM.keys $ _crInvEquipped cr)
|
||||
equipmentEffects cr = alaf Endo foldMap (useEquipment cr) (IM.keys $ _crInvEquipped cr)
|
||||
|
||||
-- a loop going over all inventory items
|
||||
invSideEff :: Creature -> World -> World
|
||||
invSideEff cr = alaf Endo foldMap f (_crInv cr) . updateHeldRootItem cr
|
||||
@@ -176,7 +167,7 @@ invRootItemEffs cr =
|
||||
(invLDT (_crInv cr))
|
||||
|
||||
invItemLocUpdate :: Creature -> LocationLDT ItemLink ComposedItem -> World -> World
|
||||
invItemLocUpdate cr loc w = doAnyEquipmentEffect cr loc $ case itm ^. itType of
|
||||
invItemLocUpdate cr loc w = doAnyEquipmentEffect loc cr $ case itm ^. itType of
|
||||
ATTACH BULLETSYNTH -> trySynthBullet loc w
|
||||
EQUIP WRIST_ECG | haspulse -> tryUseParent loc w
|
||||
_ -> w
|
||||
@@ -186,9 +177,9 @@ invItemLocUpdate cr loc w = doAnyEquipmentEffect cr loc $ 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
|
||||
doAnyEquipmentEffect :: LocationLDT ItemLink ComposedItem -> Creature -> World -> World
|
||||
doAnyEquipmentEffect loc cr = case itm ^? itLocation . ilEquipPosition . _Just of
|
||||
Just _ -> useE (_eeUse (_uequipEffect $ _itUse itm)) loc cr
|
||||
_ -> id
|
||||
where
|
||||
itm = loc ^. locLDT . ldtValue . _1
|
||||
|
||||
Reference in New Issue
Block a user