Add delay before game over
This commit is contained in:
@@ -7,6 +7,7 @@ module Dodge.Creature.Action
|
|||||||
, setMinInvSize
|
, setMinInvSize
|
||||||
, dropUnselected
|
, dropUnselected
|
||||||
, dropExcept
|
, dropExcept
|
||||||
|
, dropItem
|
||||||
-- , startReloadingWeapon
|
-- , startReloadingWeapon
|
||||||
, blinkAction
|
, blinkAction
|
||||||
, unsafeBlinkAction
|
, unsafeBlinkAction
|
||||||
|
|||||||
@@ -68,11 +68,15 @@ checkDeath :: Creature -> World -> World
|
|||||||
checkDeath cr w
|
checkDeath cr w
|
||||||
| _crHP cr > 0 = w
|
| _crHP cr > 0 = w
|
||||||
| otherwise = w
|
| otherwise = w
|
||||||
& creatures . at (_crID cr) .~ Nothing
|
-- & creatures . at (_crID cr) .~ Nothing
|
||||||
|
& removecr
|
||||||
& stopSoundFrom (CrWeaponSound (_crID cr) 0)
|
& stopSoundFrom (CrWeaponSound (_crID cr) 0)
|
||||||
& over decorations addCorpse
|
& over decorations addCorpse
|
||||||
& dropByState cr
|
& dropByState cr
|
||||||
where
|
where
|
||||||
|
removecr
|
||||||
|
| _crID cr == 0 = creatures . ix (_crID cr) . crUpdate .~ const id
|
||||||
|
| otherwise = creatures . at (_crID cr) .~ Nothing
|
||||||
addCorpse = IM.insertNewKey
|
addCorpse = IM.insertNewKey
|
||||||
$ uncurryV translate (_crOldPos cr)
|
$ uncurryV translate (_crOldPos cr)
|
||||||
$ rotate (_crDir cr)
|
$ rotate (_crDir cr)
|
||||||
@@ -88,7 +92,7 @@ internalUpdate cr = creatures . ix (_crID cr) %~
|
|||||||
-- | Drop items according to the creature state.
|
-- | Drop items according to the creature state.
|
||||||
-- TODO make sure this doesn't mess up any ItemPosition
|
-- TODO make sure this doesn't mess up any ItemPosition
|
||||||
dropByState :: Creature -> World -> World
|
dropByState :: Creature -> World -> World
|
||||||
dropByState cr w = foldr (copyInvItemToFloor cr) w $ case cr ^. crState . crDropsOnDeath of
|
dropByState cr w = foldr (dropItem cr) w $ case cr ^. crState . crDropsOnDeath of
|
||||||
DropAll -> IM.keys $ _crInv cr
|
DropAll -> IM.keys $ _crInv cr
|
||||||
DropSpecific xs -> xs
|
DropSpecific xs -> xs
|
||||||
DropAmount n -> take n $ evalState (shuffle $ IM.keys $ _crInv cr) (_randGen w)
|
DropAmount n -> take n $ evalState (shuffle $ IM.keys $ _crInv cr) (_randGen w)
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ data World = World
|
|||||||
, _genParams :: GenParams
|
, _genParams :: GenParams
|
||||||
, _genPlacements :: IM.IntMap [(Placement,Int)]
|
, _genPlacements :: IM.IntMap [(Placement,Int)]
|
||||||
, _genRooms :: IM.IntMap Room
|
, _genRooms :: IM.IntMap Room
|
||||||
|
, _deathDelay :: Maybe Int
|
||||||
}
|
}
|
||||||
|
|
||||||
newtype GenParams = GenParams
|
newtype GenParams = GenParams
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ defaultWorld = World
|
|||||||
, _genParams = GenParams M.empty
|
, _genParams = GenParams M.empty
|
||||||
, _genPlacements = IM.empty
|
, _genPlacements = IM.empty
|
||||||
, _genRooms = IM.empty
|
, _genRooms = IM.empty
|
||||||
|
, _deathDelay = Nothing
|
||||||
}
|
}
|
||||||
youLight :: TempLightSource
|
youLight :: TempLightSource
|
||||||
youLight = TLS
|
youLight = TLS
|
||||||
|
|||||||
+6
-3
@@ -269,9 +269,12 @@ markWallSeen w wl = w { _walls = IM.adjust mw (_wlID wl) $ _walls w }
|
|||||||
mw wl' = wl' {_wlSeen = True}
|
mw wl' = wl' {_wlSeen = True}
|
||||||
|
|
||||||
checkEndGame :: World -> World
|
checkEndGame :: World -> World
|
||||||
checkEndGame w
|
checkEndGame w = case _deathDelay w of
|
||||||
| _crHP (you w) < 1 = w & sideEffects %~ ( . (menuLayers .~ [gameOverMenu]))
|
Just x | x < 0 -> w & sideEffects %~ ( . (menuLayers .~ [gameOverMenu]))
|
||||||
| otherwise = w
|
& deathDelay .~ Nothing
|
||||||
|
Just _ -> w & deathDelay . _Just -~ 1
|
||||||
|
_ | _crHP (you w) < 1 -> w & deathDelay ?~ 50
|
||||||
|
_ -> w
|
||||||
|
|
||||||
updateGusts :: World -> World
|
updateGusts :: World -> World
|
||||||
updateGusts w = w
|
updateGusts w = w
|
||||||
|
|||||||
Reference in New Issue
Block a user