Skip to content
Browse files

highlight player, even if he's a monster

  • Loading branch information...
1 parent 02f6a6e commit f46dafe4d74ae4e486d9df01bf0e78aa92dc4e6f @Mikolaj Mikolaj committed Mar 20, 2011
Showing with 17 additions and 13 deletions.
  1. +2 −1 src/Display/Curses.hs
  2. +1 −1 src/Display/Gtk.hs
  3. +1 −1 src/Display/Vty.hs
  4. +6 −2 src/Display2.hs
  5. +6 −8 src/Monster.hs
  6. +1 −0 src/Perception.hs
View
3 src/Display/Curses.hs
@@ -1,7 +1,8 @@
module Display.Curses
(displayId, startup, shutdown,
display, nextEvent, setBG, setFG, setBold, Session,
- white, black, yellow, blue, magenta, red, green, attr, Display.Curses.Attr) where
+ white, black, yellow, blue, magenta, red, green, attr,
+ Display.Curses.Attr, AttrColor) where
import UI.HSCurses.Curses as C hiding (setBold)
import qualified UI.HSCurses.CursesHelper as C
View
2 src/Display/Gtk.hs
@@ -1,7 +1,7 @@
module Display.Gtk
(displayId, startup, shutdown,
display, nextEvent, setBG, setFG, setBold, Session,
- white, black, yellow, blue, magenta, red, green, attr, Attr) where
+ white, black, yellow, blue, magenta, red, green, attr, Attr, AttrColor) where
import Control.Monad
import Control.Concurrent
View
2 src/Display/Vty.hs
@@ -1,7 +1,7 @@
module Display.Vty
(displayId, startup, shutdown,
display, nextEvent, setBold, setBG, setFG, Session,
- white, black, yellow, blue, magenta, red, green, attr, Attr) where
+ white, black, yellow, blue, magenta, red, green, attr, Attr, AttrColor) where
import Graphics.Vty as V
import Data.List as L
View
8 src/Display2.hs
@@ -149,7 +149,7 @@ displayLevel session per
slevel = lvl@(Level nm hs sz@(sy,sx) ms smap nlmap lmeta) }))
msg moverlay =
let Movable { mhpmax = phpmax, mhp = php, mdir = pdir,
- mloc = ploc, mitems = pitems, mtype = ptype } =
+ mloc = ploc, mitems = pitems } =
getPlayerBody state
overlay = maybe "" id moverlay
reachable = preachable per
@@ -169,6 +169,10 @@ displayLevel session per
gold = maybe 0 (icount . fst) $ findItem (\ i -> iletter i == Just '$') pitems
hs = levelHeroList state
ms = levelMonsterList state
+ setFg color = setFG color
+ setInv color = if color == white
+ then setBG white . setFG black
+ else setBG white . setFG color
disp n msg =
display ((0,0),sz) session
(\ loc -> let tile = nlmap `lAt` loc
@@ -177,7 +181,7 @@ displayLevel session per
rea = S.member loc reachable
(rv,ra) = case L.find (\ m -> loc == mloc m) (hs ++ ms) of
_ | sTer > 0 -> viewTerrain sTer False (tterrain tile)
- Just m | sOmn || vis -> viewMovable (mtype m) (mtype m == ptype)
+ Just m | sOmn || vis -> let (sym, color) = viewMovable (mtype m) in (sym, (if mloc m == ploc then setInv else setFg) color)
_ | sSml && sml >= 0 -> viewSmell sml
| otherwise -> viewTile vis tile assocs
vision =
View
14 src/Monster.hs
@@ -142,11 +142,9 @@ newMonster loc ftp =
speed FastEye = 4
speed Nose = 11
-viewMovable :: MovableType -> Bool -> (Char, Attr -> Attr)
-viewMovable (Hero symbol name) r = (symbol,
- if r
- then setBG white . setFG black
- else setBG black . setFG white)
-viewMovable Eye _ = ('e', setFG red)
-viewMovable FastEye _ = ('e', setFG blue)
-viewMovable Nose _ = ('n', setFG green)
+-- Heroes are white, monsters are colorful.
+viewMovable :: MovableType -> (Char, AttrColor)
+viewMovable (Hero sym _) = (sym, white)
+viewMovable Eye = ('e', red)
+viewMovable FastEye = ('e', blue)
+viewMovable Nose = ('n', green)
View
1 src/Perception.hs
@@ -39,6 +39,7 @@ perception_ state@(State { slevel = Level { lmap = lmap },
reachable = S.unions (L.map preachable pers)
visible = S.unions (L.map pvisible pers)
-- TODO: update individual hero perceptions here; see https://github.com/Mikolaj/LambdaHack/issues/issue/31
+ -- TODO: do perception also for a monster under player control
in Perception reachable visible
perception :: FovMode -> Loc -> LMap -> Perception

0 comments on commit f46dafe

Please sign in to comment.
Something went wrong with that request. Please try again.