43 lines
1.3 KiB
Haskell
43 lines
1.3 KiB
Haskell
module Dodge.Item.Attachment
|
|
( charFiringStratI
|
|
, changeFuse
|
|
) where
|
|
import Dodge.Data
|
|
import Dodge.ChainEffect
|
|
import Dodge.Default
|
|
|
|
import Control.Lens hiding ((|>),(<|))
|
|
import Data.Sequence
|
|
import Data.Maybe
|
|
import qualified IntMapHelp as IM
|
|
|
|
|
|
charFiringStratI
|
|
:: [(Char, ChainEffect)] -- ^ Different firing effects for different characters
|
|
-> ChainEffect
|
|
charFiringStratI strats eff item cr w = case w ^? creatures . ix cid . crInv
|
|
. ix (crSel $ _creatures w IM.! cid) . itAttachment . atCharMode of
|
|
Just (c :<| _) -> fromMaybe id (Prelude.lookup c strats) eff item cr w
|
|
_ -> w
|
|
where
|
|
cid = _crID cr
|
|
|
|
changeFuse
|
|
:: Float -- ^ Old fuse time
|
|
-> Creature -- ^ Inventory item reference (I believe)
|
|
-> Item
|
|
-> Item
|
|
changeFuse scrollAmount _ it = it
|
|
& ( itAttachment .~ AttachFuse newTime )
|
|
& ( itUse . useAim . aimZoom .~ defaultItZoom{_itZoomMax = zm, _itZoomMin = zm} )
|
|
where
|
|
oldTime = _atFuseTime $ _itAttachment it
|
|
newTime = min 90 $ max 20 $ oldTime - round (5 * scrollAmount)
|
|
zm = 50 / fromIntegral newTime
|
|
|
|
--removeItAttachment :: Int -> Int -> World -> World
|
|
--removeItAttachment i _ w = w & creatures . ix i . crInv . ix itRef . itAttachment .~ NoItAttachment
|
|
-- where
|
|
-- cr = _creatures w IM.! i
|
|
-- itRef = _crInvSel cr
|