Permalink
Browse files

misc tweaks

  • Loading branch information...
Mikolaj committed Feb 22, 2011
1 parent 8d82c19 commit 44268423664cb114f82714bfa2d5a275466d4eee
Showing with 22 additions and 1 deletion.
  1. +10 −0 src/Action.hs
  2. +6 −1 src/Actions.hs
  3. +1 −0 src/Keys.hs
  4. +5 −0 src/Turn.hs
View
@@ -3,6 +3,7 @@ module Action where
import Control.Monad
import Control.Monad.State hiding (State)
+import Data.List as L
-- import System.IO (hPutStrLn, stderr) -- just for debugging
import Perception
@@ -163,6 +164,15 @@ messageMoreConfirm msg =
messageMore :: Message -> Action ()
messageMore msg = messageMoreConfirm msg >> return ()
+-- | Add "-more-" to the current message, await confirmation, clear messages.
+messageAddMore :: Action Bool
+messageAddMore = do
+ messageAdd (L.tail more) -- delete the space at the start
+ display
+ b <- session getConfirm
+ resetMessage
+ return b
+
-- | Print a yes/no question and return the player's answer.
messageYesNo :: Message -> Action Bool
messageYesNo msg =
View
@@ -700,7 +700,12 @@ moveOrAttack allowAttacks autoOpen actor dir
-- Focus on the attacked hero, if any. This is also handy for
-- selecting adjacent hero by bumping into him (without running).
-- TODO: let running switch position of hero and another hero/monster.
- maybe (return False) (selectHero . fst) attHero
+ case attHero of
+ Nothing -> return ()
+ Just (i, _) -> do
+ b <- selectHero i
+ -- extra prompt, especially for when many heroes attacked in one turn
+ when (b && actor /= APlayer) $ messageAddMore >> return ()
-- At the moment, we check whether there is a monster before checking
-- accessibility, i.e., we can attack a monster on a blocked location.
-- For instance, a monster on an open door can be attacked diagonally,
View
@@ -22,6 +22,7 @@ data Key =
deriving (Ord, Eq)
showKey :: Key -> String
+showKey (Char ' ') = "<space>" -- warnings about "command ( )" look wrong
showKey (Char c) = [c]
showKey Esc = "<escape>"
showKey Return = "<return>"
View
@@ -97,6 +97,11 @@ handleMonsters =
| otherwise -> -- monster m should move; we temporarily remove m from the level
-- TODO: removal isn't nice. Actor numbers currently change during
-- a move. This could be cleaned up.
+ -- Note: however this has a nice side-effect: monsters
+ -- move in reversed order wrt the previous turn,
+ -- so there is 2 times less changes of focus
+ -- (in particular hero selection) in case of two
+ -- simultaneous battles.
do
modify (updateLevel (updateMonsters (const ms)))
handleMonster m

0 comments on commit 4426842

Please sign in to comment.