2018-11-17 19:11:36 +01:00
|
|
|
{-# LANGUAGE DeriveGeneric #-}
|
|
|
|
module Message.Client (
|
|
|
|
Message(..)
|
|
|
|
) where
|
|
|
|
|
2018-12-02 19:43:24 +01:00
|
|
|
import Data.Aeson (FromJSON(..), ToJSON(..), genericParseJSON, genericToEncoding, defaultOptions)
|
2018-11-17 19:11:36 +01:00
|
|
|
import GHC.Generics (Generic)
|
2018-12-30 23:40:51 +01:00
|
|
|
import qualified Area (Key)
|
|
|
|
import Game (Game, Direction)
|
2018-11-17 19:11:36 +01:00
|
|
|
|
|
|
|
data Message =
|
|
|
|
NewGame
|
|
|
|
| Resume {
|
|
|
|
game :: Game
|
2018-12-30 23:40:51 +01:00
|
|
|
}
|
|
|
|
| Load {
|
|
|
|
area :: Area.Key
|
|
|
|
}
|
|
|
|
| Move {
|
|
|
|
to :: Direction
|
|
|
|
}
|
|
|
|
deriving (Generic)
|
2018-11-17 19:11:36 +01:00
|
|
|
|
2018-12-02 19:43:24 +01:00
|
|
|
instance ToJSON Message where
|
|
|
|
toEncoding = genericToEncoding defaultOptions
|
|
|
|
|
2018-11-17 19:11:36 +01:00
|
|
|
instance FromJSON Message where
|
|
|
|
parseJSON = genericParseJSON defaultOptions
|