module Dodge.ItEffect where import Dodge.Euse import Dodge.Data import Dodge.LightSource.Torch import Control.Lens doInvEffect :: ItInvEffect -> Item -> Creature -> World -> World doInvEffect iie = case iie of NoInvEffect -> const $ const id RewindEffect -> rewindEffect -- ResetAttachmentEffect -> resetAttachmentEffect EffectIfHeld f g -> onOffEff f g CreateHeldLight -> createHeldLight CreateShieldWall -> createShieldWall RemoveShieldWall -> removeShieldWall EffectWhileHeld f -> onOffEff f NoInvEffect doFloorEffect :: ItFloorEffect -> Int -> World -> World doFloorEffect NoFloorEffect = const id onOffEff :: ItInvEffect -> ItInvEffect -> Item -> Creature -> World -> World onOffEff f g it | _itIsHeld it = doInvEffect f it | otherwise = doInvEffect g it rewindEffect :: Item -> Creature -> World -> World rewindEffect itm cr w | Just invid == _crLeftInvSel cr = w & cWorld . rewindWorlds %~ (take maxcharge . (cw : )) & ptrWpCharge .~ length (_rewindWorlds (_cWorld w)) | otherwise = w & cWorld . rewindWorlds .~ [] & ptrWpCharge .~ 0 where invid = _ipInvID $ _itLocation itm ptrWpCharge = cWorld . creatures . ix (_crID cr) . crInv . ix invid . itUse . leftConsumption . wpCharge maxcharge = itm ^?! itUse . leftConsumption . wpMaxCharge cw = _cWorld w & rewindWorlds .~ [] --resetAttachmentEffect :: Item -> Creature -> World -> World --resetAttachmentEffect itm cr w -- | _ieCounter iteff < 0 = w & pointToIt . itAttachment .~ NoItAttachment -- | otherwise = w & pointToIt . itEffect . ieCounter -~ 1 -- where -- iteff = _itEffect itm -- invid = _ipInvID $ _itLocation itm -- pointToIt = cWorld . creatures . ix (_crID cr) . crInv . ix invid createHeldLight :: Item -> Creature -> World -> World createHeldLight itm cr = createTorchLightOffset cr itm 0