Move held item scrolling into dedicated datatype

This commit is contained in:
2022-07-20 15:17:56 +01:00
parent 2755a4ffdd
commit 2c6e5e818a
10 changed files with 79 additions and 58 deletions
+37
View File
@@ -0,0 +1,37 @@
module Dodge.HeldScroll
( doHeldScroll
) where
import Dodge.Data
import Dodge.Item.Weapon.ZoomScope
import Control.Lens hiding ((|>),(<|))
import Data.Sequence
doHeldScroll :: HeldScroll -> Float -> Creature -> Item -> Item
doHeldScroll hs = case hs of
HeldScrollDoNothing -> const . const id
HeldScrollZoom -> zoomLongGun
HeldScrollCharMode -> scrollCharMode
scrollCharMode
:: Float -- ^ Amount scrolled
-> Creature
-> Item
-> Item
scrollCharMode x _
| x > 0 = incCharMode
| x < 0 = decCharMode
| otherwise = id
incCharMode
:: Item
-> Item
incCharMode = itAttachment . atCharMode %~ cycleL
where
cycleL (x :<| xs) = xs |> x
cycleL xs = xs
decCharMode
:: Item
-> Item
decCharMode = itAttachment . atCharMode %~ cycleR
where
cycleR (xs :|> x) = x <| xs
cycleR xs = xs