Files
loop/src/Dodge/ItEffect.hs
T
2024-12-19 23:40:04 +00:00

60 lines
2.3 KiB
Haskell

{-# LANGUAGE LambdaCase #-}
module Dodge.ItEffect (
doInvEffect,
) where
import Control.Lens
import Dodge.Data.World
import Dodge.Euse
doInvEffect :: ItInvEffect -> Item -> Creature -> World -> World
doInvEffect = \case
NoInvEffect -> const $ const id
EffectRootNotroot f g -> rootNotrootEff f g
CreateShieldWall -> createShieldWall
RemoveShieldWall -> removeShieldWall
EffectWhileRoot f -> rootNotrootEff f NoInvEffect
EffectWhileAttached f -> effectWhileAttached f
rootNotrootEff :: ItInvEffect -> ItInvEffect -> Item -> Creature -> World -> World
rootNotrootEff f g it
| it ^? itLocation . ilIsRoot == Just True = doInvEffect f it
| otherwise = doInvEffect g it
effectWhileAttached :: ItInvEffect -> Item -> Creature -> World -> World
effectWhileAttached f it
| it ^? itLocation . ilIsAttached == Just True = doInvEffect f it
| otherwise = const id
--timeScrollEffect :: Item -> Creature -> World -> World
--timeScrollEffect itm _ w = w & timeFlow .~ ScrollTimeFlow
-- { _scrollSmoothing = 0
-- , _reverseAmount = itm ^?! itUse . leftConsumption . wpCharge
-- , _futureWorlds = []
-- }
--setItemCharge :: Int -> Item -> Creature -> World -> World
--setItemCharge i itm cr w =
-- w & ptrWpCharge %~ const i
-- where
-- invid = _ilInvID $ _itLocation itm
-- ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
--
--chargeIfInInventory :: Item -> Creature -> World -> World
--chargeIfInInventory itm cr w =
-- w & ptrWpCharge %~ (min maxcharge . (+ 1))
-- where
-- invid = _ilInvID $ _itLocation itm
-- ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
-- maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge
--
--chargeIfEquipped :: Item -> Creature -> World -> World
--chargeIfEquipped itm cr w
-- | invid `IM.member` (w ^. cWorld . lWorld . imHotkeys) = w &
-- ptrWpCharge %~ (min maxcharge . (+ 1))
-- | otherwise = w & ptrWpCharge .~ 0
-- where
-- invid = _ilInvID $ _itLocation itm
-- ptrWpCharge = cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge
-- maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge