{-# LANGUAGE DeriveGeneric #-} module Message.Client ( Message(..) ) where import Data.Aeson (FromJSON(..), ToJSON(..), genericParseJSON, genericToEncoding, defaultOptions) import GHC.Generics (Generic) import qualified Area (Key) import Game (Game, Direction) data Message = NewGame | Resume { game :: Game } | Load { area :: Area.Key } | Move { to :: Direction } deriving (Generic) instance ToJSON Message where toEncoding = genericToEncoding defaultOptions instance FromJSON Message where parseJSON = genericParseJSON defaultOptions