Files
loop/src/Dodge/HeldScroll.hs
T

28 lines
768 B
Haskell

module Dodge.HeldScroll (
doHeldScroll,
canHeldScrollAttach,
) where
import Control.Lens hiding ((<|), (|>))
import Data.Sequence
import Dodge.Data.World
doHeldScroll :: Int -> ScrollAttachParams -> Float -> World -> World
doHeldScroll invid hs x w = case hs of
ZoomScrollParams{}-> w
CharScrollParams{} -> w & cWorld . lWorld . creatures . ix 0 . crInv . ix invid . itUse . attachParams . scrollAttachParams . scrollChar %~ cycleSignum x
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
canHeldScrollAttach :: Item -> ScrollAttachParams -> Bool
canHeldScrollAttach _ _ = True