diff --git a/src/Game.hs b/src/Game.hs index 2b9cb47..2904580 100644 --- a/src/Game.hs +++ b/src/Game.hs @@ -28,13 +28,9 @@ import qualified Hanafuda.Player (Player(..), Players(..)) import qualified Hanafuda.KoiKoi (Action(..), Game(..), Environment, Mode(..), Move(..), Score, Source(..), Step(..), Yaku(..), new, play) import GHC.Generics -deriving instance Generic Hanafuda.Card deriving instance Generic Hanafuda.Flower -deriving instance Generic Hanafuda.KoiKoi.Action deriving instance Generic Hanafuda.KoiKoi.Mode -deriving instance Generic Hanafuda.KoiKoi.Move deriving instance Generic Hanafuda.KoiKoi.Yaku -deriving instance Generic Hanafuda.KoiKoi.Source deriving instance Generic Hanafuda.KoiKoi.Step deriving instance Generic1 (Hanafuda.Player.Player Player.Key) deriving instance Generic1 (Hanafuda.Player.Players Player.Key) @@ -46,26 +42,14 @@ deriving instance Generic T instance ToJSON T where toEncoding = genericToEncoding JSON.defaultOptions -instance FromJSON Hanafuda.Card -instance ToJSON Hanafuda.Card - instance ToJSON Hanafuda.Flower instance ToJSON Hanafuda.Pack where toJSON = toJSON . Hanafuda.cardsOfPack toEncoding = toEncoding . Hanafuda.cardsOfPack -instance ToJSON Hanafuda.KoiKoi.Action - instance ToJSON Hanafuda.KoiKoi.Mode -instance FromJSON Hanafuda.KoiKoi.Move where - parseJSON = genericParseJSON JSON.singleLCField -instance ToJSON Hanafuda.KoiKoi.Move where - toEncoding = genericToEncoding JSON.singleLCField - -instance ToJSON Hanafuda.KoiKoi.Source - instance ToJSON Hanafuda.KoiKoi.Step where toEncoding = genericToEncoding JSON.defaultOptions diff --git a/src/Message.hs b/src/Message.hs index 5ef1771..1720ef0 100644 --- a/src/Message.hs +++ b/src/Message.hs @@ -30,33 +30,6 @@ import qualified App (Context(..), T, connection, debug, server) import qualified Hanafuda.KoiKoi as KoiKoi (Action, Game(..), Move(..)) import GHC.Generics (Generic) -data FromClient = - Answer {accept :: Bool} - | Invitation {to :: Player.Key} - | LogIn {name :: Text} - | LogOut - | Play {move :: KoiKoi.Move} - | Quit - | Ping - deriving (Generic) - -instance ToJSON FromClient where - toEncoding = genericToEncoding defaultOptions -instance FromJSON FromClient where - parseJSON = genericParseJSON defaultOptions - -data T = - Relay {from :: Player.Key, message :: FromClient} - | Welcome {room :: Server.T, key :: Player.Key} - | Update {alone :: [Player.Key], paired :: [Player.Key]} - | Game {game :: Value, logs :: [KoiKoi.Action]} - | Pong - | Error {error :: String} - deriving (Generic) - -instance ToJSON T where - toEncoding = genericToEncoding defaultOptions - sendTo :: [Player.Key] -> T -> App.T () sendTo playerKeys obj = do sessions <- getSessions <$> App.server