Files
loop/src/Dodge/HeldScroll.hs
T

42 lines
1.3 KiB
Haskell

module Dodge.HeldScroll (
doHeldScroll,
) where
import Dodge.Base.You
import Control.Lens hiding ((<|), (|>))
import Data.Sequence
import Dodge.Data.Creature
import Dodge.Data.World
import Dodge.Item.Weapon.ZoomScope
--import LensHelp hiding ((|>), (<|))
-- should be able to just import data.item
doHeldScroll :: HeldScroll -> Float -> Creature -> World -> World
doHeldScroll hs = case hs of
HeldScrollDoNothing -> const . const id
HeldScrollZoom -> overYourItem zoomLongGun
HeldScrollCharMode{} -> overYourItem $ \x _ -> itUse . heldScroll . hsCharMode %~ cycleSignum x
HeldScrollTime -> doScrollTime
HeldScrollInt{} -> undefined
where
overYourItem f x cr w = w & cWorld . lWorld . creatures . ix 0 . crInv . ix (crSel $ you w) %~ f x cr
doScrollTime :: Float -> Creature -> World -> World
doScrollTime _ _ w = w
-- | x > 0 = case _futureWorlds $ _cwTime w of
-- (w':ws) -> w -- & cWorld .~ w'
-- -- & cwTime . futureWorlds %~ tail
-- -- & cwTime . rewindWorlds .:~ _cWorld w
-- _ -> w
-- | otherwise = w
cycleSignum :: Float -> Seq a -> Seq a
cycleSignum x
| x > 0 = cycleL
| otherwise = cycleR
cycleL, cycleR :: Seq a -> Seq a
cycleL (x :<| xs) = xs |> x
cycleL xs = xs
cycleR (xs :|> x) = x <| xs
cycleR xs = xs