Start implementing attachable scroll items
This commit is contained in:
+8
-14
@@ -1,25 +1,16 @@
|
||||
module Dodge.HeldScroll (
|
||||
doHeldScroll,
|
||||
canHeldScrollAttach,
|
||||
) where
|
||||
|
||||
--import Dodge.Base.You
|
||||
import Control.Lens hiding ((<|), (|>))
|
||||
import Data.Sequence
|
||||
import Dodge.Data.Creature
|
||||
import Dodge.Data.World
|
||||
import Data.Maybe
|
||||
--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 -> const . const id
|
||||
HeldScrollCharMode{} -> overYourItem $ \x _ -> itUse . heldScroll . hsCharMode %~ cycleSignum x
|
||||
where
|
||||
overYourItem f x cr w = fromMaybe w $ do
|
||||
i <- cr ^? crManipulation . manObject . inInventory . ispItem
|
||||
return $ w & cWorld . lWorld . creatures . ix 0 . crInv . ix i %~ f x cr
|
||||
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
|
||||
@@ -31,3 +22,6 @@ cycleL (x :<| xs) = xs |> x
|
||||
cycleL xs = xs
|
||||
cycleR (xs :|> x) = x <| xs
|
||||
cycleR xs = xs
|
||||
|
||||
canHeldScrollAttach :: Item -> ScrollAttachParams -> Bool
|
||||
canHeldScrollAttach _ _ = True
|
||||
|
||||
Reference in New Issue
Block a user