about summary refs log blame commit diff
path: root/src/Xanthous/Entities/Environment.hs
blob: 90fa05315a57a2eab4c2011922947310a09525ed (plain) (tree)
1
2
3
4
5
6
7
8
9








                                                                                
                                                         







                                                                                


                          







                                                       
module Xanthous.Entities.Environment
  ( Wall(..)
  ) where
--------------------------------------------------------------------------------
import Xanthous.Prelude
import Test.QuickCheck
import Brick (str)
import Brick.Widgets.Border.Style (unicode)
--------------------------------------------------------------------------------
import Xanthous.Entities (Draw(..), entityIs, Entity(..))
import Xanthous.Entities.Draw.Util
import Xanthous.Data
--------------------------------------------------------------------------------

data Wall = Wall
  deriving stock (Show, Eq, Ord, Generic, Enum)
  deriving anyclass (CoArbitrary, Function)

instance Entity Wall where
  blocksVision _ = True

instance Arbitrary Wall where
  arbitrary = pure Wall

instance Draw Wall where
  drawWithNeighbors neighs _wall =
    str . pure . borderFromEdges unicode $ wallEdges
    where
      wallEdges = any (entityIs @Wall) <$> edges neighs