Using the new «public» Game type in Messages, will need to re-import everything that was done in the server's Game module before

This commit is contained in:
Tissevert 2019-08-18 22:13:54 +02:00
parent 607b253f3b
commit 2b196c0075

View file

@ -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)