diff --git a/src/Hanafuda/Message.hs b/src/Hanafuda/Message.hs index 86a23eb..4af735c 100644 --- a/src/Hanafuda/Message.hs +++ b/src/Hanafuda/Message.hs @@ -142,14 +142,24 @@ instance ToJSON Hanafuda.Flower where toEncoding = genericToEncoding defaultOptions data PrivateState = PrivateState { - opponent :: Player KoiKoi.Score + opponentHand :: Hanafuda.Pack , deck :: [Hanafuda.Card] } deriving Generic +data PublicPlayer = PublicPlayer { + meld :: Hanafuda.Pack + , yakus :: KoiKoi.Score + } deriving Generic + +instance FromJSON PublicPlayer +instance ToJSON PublicPlayer where + toEncoding = genericToEncoding defaultOptions + data PublicState = PublicState { mode :: KoiKoi.Mode , scores :: Scores KoiKoi.Score , month :: Hanafuda.Flower + , players :: Map PlayerID PublicPlayer , playing :: PlayerID , winning :: PlayerID , oyake :: PlayerID @@ -170,7 +180,7 @@ instance ToJSON ByteString where toEncoding = toEncoding . decodeUtf8 data PublicGame = PublicGame { - player :: Player KoiKoi.Score + playerHand :: Hanafuda.Pack , privateState :: ByteString , publicState :: PublicState , publicSignature :: ByteString @@ -184,7 +194,7 @@ data T = Relay {from :: PlayerID, message :: FromClient} | Welcome {room :: Room, key :: PlayerID} | Update {alone :: [PlayerID], paired :: [PlayerID]} - | Game {game :: PublicGame, logs :: [KoiKoi.Action]} + | Game {state :: PublicGame, logs :: [KoiKoi.Action]} | Pong | Error {error :: String} deriving (Generic)