Add files, minimal working rewind gun that must be equipped to charge

This commit is contained in:
2021-11-27 11:49:23 +00:00
parent e7ea7377e2
commit fe37f208da
3 changed files with 29 additions and 2 deletions
+5 -2
View File
@@ -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
+9
View File
@@ -0,0 +1,9 @@
module ListHelp
(module Data.List
,initOrNull
)where
import Data.List
initOrNull :: [a] -> [a]
initOrNull [] = []
initOrNull xs = init xs
+15
View File
@@ -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'