Permalink
Browse files

all heroes (not only the player) regenrate at once

That's because we really want hero selection to be a purely UI distinction;
otherwise players will waste time micromanaging cycling among heroes before
the end of the turn.
  • Loading branch information...
1 parent 790861c commit e9b28bac6e6b068d37d9741b20ddbc139b940445 @Mikolaj Mikolaj committed Feb 5, 2011
Showing with 14 additions and 6 deletions.
  1. +12 −4 src/Actions.hs
  2. +2 −2 src/Turn.hs
View
@@ -154,8 +154,12 @@ remember =
let rememberLoc = M.update (\ (t,_) -> Just (t,t))
modify (updateLevel (updateLMap (\ lmap -> foldr rememberLoc lmap vis)))
-checkHeroDeath :: Action ()
-checkHeroDeath = -- TODO: for now, quit only when the last hero dies. TODO: check if it should have Hero or Player in the name (is it about the current hero?)
+-- | Remove dead heroes, check if game over.
+-- For now we only check the selected hero, but if poison, etc. is implemented,
+-- we'd need to check all heroes on level.
+-- TODO: implement survivorsCarryOn==True mode (game over when last hero dies).
+checkPartyDeath :: Bool -> Action ()
+checkPartyDeath _survivorsCarryOn =
do
player <- gets splayer
let php = mhp player
@@ -706,5 +710,9 @@ regenerate actor =
do
time <- gets stime
-- TODO: remove hardcoded time interval, regeneration should be an attribute of the monster
- when (time `mod` 1500 == 0) $
- updateActor actor (\ m -> m { mhp = min (mhpmax m) (mhp m + 1) })
+ let upd m = m { mhp = min (mhpmax m) (mhp m + 1) }
+ when (time `mod` 1500 == 0) $ do
+ updateActor actor upd
+ -- ugly, but we really want hero selection to be a purely UI distinction
+ when (actor == APlayer) $
+ modify (updateLevel (updateHeroes (IM.map upd)))
View
@@ -60,8 +60,8 @@ handle =
state <- get
let ptime = mtime (splayer state) -- time of hero's next move
let time = stime state -- current game time
- checkHeroDeath -- hero can die even if it's not the hero's turn
- regenerate APlayer -- hero can regenerate even if it's not the hero's turn
+ checkPartyDeath True -- any hero can die even if it's not the player's turn
+ regenerate APlayer -- heroes regenerate even if outside the player's turn
debug $ "handle: time check. ptime = " ++ show ptime ++ ", time = " ++ show time
if ptime > time
then do

0 comments on commit e9b28ba

Please sign in to comment.