diff --git a/src/Hanafuda/Message.hs b/src/Hanafuda/Message.hs index bb3bd98..21429b9 100644 --- a/src/Hanafuda/Message.hs +++ b/src/Hanafuda/Message.hs @@ -7,6 +7,7 @@ module Hanafuda.Message ( T(..) , FromClient(..) , PlayerStatus(..) + , PublicGame , Room ) where @@ -23,7 +24,7 @@ import qualified Data.Text as Text (pack) import GHC.Generics (Generic) import qualified Hanafuda (Card(..)) import Hanafuda.Key (Key(..), getKey) -import Hanafuda.KoiKoi (PlayerKey) +import Hanafuda.KoiKoi (PlayerKey, GameBlueprint(..)) import qualified Hanafuda.KoiKoi as KoiKoi (Action(..), Game(..), Move(..), Source(..)) deriving instance Generic PlayerKey @@ -84,11 +85,18 @@ instance ToJSON KoiKoi.Source deriving instance Generic KoiKoi.Action instance ToJSON KoiKoi.Action +type PublicGame = GameBlueprint Int + +deriving instance Generic PublicGame +instance FromJSON PublicGame +instance ToJSON PublicGame where + toEncoding = genericToEncoding defaultOptions + data T = Relay {from :: PlayerKey, message :: FromClient} | Welcome {room :: Room, key :: PlayerKey} | Update {alone :: [PlayerKey], paired :: [PlayerKey]} - | Game {game :: Value, logs :: [KoiKoi.Action]} + | Game {game :: PublicGame, logs :: [KoiKoi.Action]} | Pong | Error {error :: String} deriving (Generic)