about summary refs log tree commit diff
path: root/src/Xanthous/Entities/Environment.hs
blob: f5301f94adf25710405141f3289a47582679782b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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)
import Xanthous.Entities.Draw.Util
import Xanthous.Data
--------------------------------------------------------------------------------

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

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