Taking stuff out of Game and Message to declare them in the new APILanguage lib
This commit is contained in:
parent
ac114c16df
commit
d54d97b84d
2 changed files with 0 additions and 43 deletions
16
src/Game.hs
16
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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue