about summary refs log tree commit diff
path: root/src/Xanthous/Data/EntityMap/Graphics.hs
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2019-09-29T14·54-0400
committerGriffin Smith <root@gws.fyi>2019-09-29T14·54-0400
commit05da490185e970b2cfdf6c61f69932fa373993f6 (patch)
tree0fa9be2182e1359ce39d600089f6937bfdccd3aa /src/Xanthous/Data/EntityMap/Graphics.hs
parentec39dc0a5bed58e0b0b48eeac98e0fd0ceaa65db (diff)
Gormlaks attack back
When gormlaks see the character, they step towards them and attack
dealing 1 damage when adjacent. Characters have hitpoints now, displayed
at the bottom of the game screen, and when the game is over they die.
Diffstat (limited to 'src/Xanthous/Data/EntityMap/Graphics.hs')
-rw-r--r--src/Xanthous/Data/EntityMap/Graphics.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/Xanthous/Data/EntityMap/Graphics.hs b/src/Xanthous/Data/EntityMap/Graphics.hs
index 3124c6a334cc..ace5ae49e804 100644
--- a/src/Xanthous/Data/EntityMap/Graphics.hs
+++ b/src/Xanthous/Data/EntityMap/Graphics.hs
@@ -4,6 +4,7 @@ module Xanthous.Data.EntityMap.Graphics
   ( visiblePositions
   , visibleEntities
   , linesOfSight
+  , canSee
   ) where
 --------------------------------------------------------------------------------
 import Xanthous.Prelude hiding (lines)
@@ -49,3 +50,7 @@ visibleEntities pos visionRadius
   . map (\(p, es) -> over _2 (Positioned p) <$> es)
   . fold
   . linesOfSight pos visionRadius
+
+canSee :: Entity e => (e -> Bool) -> Position -> Word -> EntityMap e -> Bool
+canSee match pos radius = any match . visibleEntities pos radius
+-- ^ this might be optimizable