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


                                  
              
         
                                                                                

                       

                                          
            
                                                                                
                        
                             
                                                                                
 
                          


                                    
                                           
                      



                   




                                                                
 


                               
                                  
                              


                        





                                            
{-# LANGUAGE TemplateHaskell #-}
module Xanthous.Entities.Character
  ( Character(..)
  , mkCharacter
  , pickUpItem
  ) where
--------------------------------------------------------------------------------
import Xanthous.Prelude
import Test.QuickCheck
import Test.QuickCheck.Instances.Vector ()
import Test.QuickCheck.Arbitrary.Generic
import Brick
--------------------------------------------------------------------------------
import Xanthous.Entities
import Xanthous.Entities.Item
--------------------------------------------------------------------------------

data Character = Character
  { _inventory :: !(Vector Item)
  }
  deriving stock (Show, Eq, Generic)
  deriving anyclass (CoArbitrary, Function)
makeLenses ''Character

scrollOffset :: Int
scrollOffset = 5

instance Draw Character where
  draw _ = visibleRegion rloc rreg $ str "@"
    where
      rloc = Location (negate scrollOffset, negate scrollOffset)
      rreg = (2 * scrollOffset, 2 * scrollOffset)

instance Entity Character where
  blocksVision _ = False

instance Arbitrary Character where
  arbitrary = genericArbitrary

mkCharacter :: Character
mkCharacter = Character
  { _inventory = mempty
  }

pickUpItem :: Item -> Character -> Character
pickUpItem item = inventory %~ (item <|)