{-# LANGUAGE DeriveGeneric #-} module Library.Types.Map where import Data.Matrix import GHC.Generics import Graphics.Vty -- internal imports import Library.Types.Player import Data.Aeson (ToJSON, FromJSON) -- | Data object for storing the client's state data ClientState = ClientState { clientVty :: Vty -- ^ Context object for graphics , clientGameOver :: Bool -- ^ client game over (contestant died) } -- | Type synonym for the Map. Translates to a Matrix of 'Tile's type ServerMap = Matrix Tile -- | Type synonym for the Map. Translates to a Matrix of 'Maybe Tile's type ClientMap = Matrix (Maybe Tile) instance ToJSON ClientMap instance FromJSON ClientMap data Tile = Air -- ^ walkable area | Wall -- ^ obstacle deriving (Show, Eq, Generic) instance ToJSON Tile instance FromJSON Tile data Arena = Arena { arenaMap :: ServerMap , arenaSpawners :: [Spawner] } deriving (Show, Eq) data Spawner = Spawner { spawnerPowerup :: Wand -- ^ Which 'Powerup' is being spawned , spawnerReloadTime :: Int -- ^ How long does it take for the 'Powerup' to reappear , spawnerState :: SpawnerState , spawnerReloadTTL :: Float , spawnerPosition :: Position -- ^ Position of the `Spawner` on the map } deriving (Show, Eq) data SpawnerState = SpawnerFull | SpawnerEmpty deriving (Eq, Show) data MapSlice = MapSlice { msViewMap :: ClientMap , msContents :: [Effigy] } deriving (Eq, Show, Generic) instance ToJSON MapSlice instance FromJSON MapSlice data Effigy = Effigy { effPosition :: Position , effType :: EffigyType } deriving (Eq, Show, Generic) instance ToJSON Effigy instance FromJSON Effigy data EffigyType = EffZap | EffBigZap | EffFire | EffIce | EffBigWand | EffFireWand | EffIceWand | EffWizard | EffCorpse deriving (Eq, Show, Generic) instance ToJSON EffigyType instance FromJSON EffigyType