Add FromClient messages to handle game sync at reconnection and move logs into PublicGame data structure for simplicity

This commit is contained in:
Tissevert 2020-01-20 22:57:13 +01:00
parent 4c404df4d6
commit 59c467e988

View file

@ -80,6 +80,9 @@ data FromClient =
| Answer {accept :: Bool, to :: PlayerID} | Answer {accept :: Bool, to :: PlayerID}
| Invitation {to :: PlayerID} | Invitation {to :: PlayerID}
| Play {move :: KoiKoi.Move, onGame :: PublicGame} | Play {move :: KoiKoi.Move, onGame :: PublicGame}
| Share {gameSave :: PublicGame}
| Sync {latestKnown :: Coordinates, to :: PlayerID}
| Yield {onGameID :: GameID, to :: PlayerID}
| Quit | Quit
| Ping | Ping
deriving (Generic, Show) deriving (Generic, Show)
@ -196,6 +199,7 @@ instance ToJSON ByteString where
data PublicGame = PublicGame { data PublicGame = PublicGame {
nonce :: ByteString nonce :: ByteString
, logs :: [KoiKoi.Action]
, playerHand :: Hanafuda.Pack , playerHand :: Hanafuda.Pack
, private :: ByteString , private :: ByteString
, public :: PublicState , public :: PublicState
@ -212,7 +216,7 @@ data T =
| Okaeri {room :: Room} | Okaeri {room :: Room}
| LogIn {from :: PlayerID, as :: Text} | LogIn {from :: PlayerID, as :: Text}
| LogOut {from :: PlayerID} | LogOut {from :: PlayerID}
| Game {state :: PublicGame, logs :: [KoiKoi.Action]} | Game {state :: PublicGame}
| Pong | Pong
| Error {error :: String} | Error {error :: String}
deriving (Generic) deriving (Generic)