diff --git a/src/Dodge/Item/Weapon/Utility.hs b/src/Dodge/Item/Weapon/Utility.hs index e2f21c5b9..ecce5818a 100644 --- a/src/Dodge/Item/Weapon/Utility.hs +++ b/src/Dodge/Item/Weapon/Utility.hs @@ -26,8 +26,11 @@ rewindGun = defaultGun , _itUse = Left $ \cr invid -> useRewindGun (_crInv cr IM.! invid) cr } rewindEffect :: ItEffect -> Creature -> Int -> World -> World -rewindEffect _ cr invid w = w & rewindWorlds %~ (take 250 . (w' : )) - & creatures . ix (_crID cr) . crInv . ix invid . wpLoadedAmmo .~ length (_rewindWorlds w) +rewindEffect _ cr invid w + | Just invid == _crLeftInvSel cr = w & rewindWorlds %~ (take 250 . (w' : )) + & creatures . ix (_crID cr) . crInv . ix invid . wpLoadedAmmo .~ length (_rewindWorlds w) + | otherwise = w & rewindWorlds .~ [] + & creatures . ix (_crID cr) . crInv . ix invid . wpLoadedAmmo .~ 0 where w' = w & rewindWorlds .~ [] & rewinding .~ True diff --git a/src/ListHelp.hs b/src/ListHelp.hs new file mode 100644 index 000000000..7669c8bc1 --- /dev/null +++ b/src/ListHelp.hs @@ -0,0 +1,9 @@ +module ListHelp + (module Data.List + ,initOrNull + )where +import Data.List + +initOrNull :: [a] -> [a] +initOrNull [] = [] +initOrNull xs = init xs diff --git a/src/MaybeHelp.hs b/src/MaybeHelp.hs new file mode 100644 index 000000000..11be7d46d --- /dev/null +++ b/src/MaybeHelp.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE StrictData #-} +module MaybeHelp where +import Control.Lens + +-- | Strict maybe +data Maybe' a + = Just' {_Just' :: a } + | Nothing' + +fromJust' :: Maybe' a -> a +fromJust' mx = case mx of + Just' x -> x + Nothing' -> error "no fromJust'" +makeLenses ''Maybe'