From 59c467e988c3243566f10cf761aef22278034115 Mon Sep 17 00:00:00 2001 From: Tissevert Date: Mon, 20 Jan 2020 22:57:13 +0100 Subject: [PATCH] Add FromClient messages to handle game sync at reconnection and move logs into PublicGame data structure for simplicity --- src/Hanafuda/Message.hs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Hanafuda/Message.hs b/src/Hanafuda/Message.hs index 8dd83cc..4506a7f 100644 --- a/src/Hanafuda/Message.hs +++ b/src/Hanafuda/Message.hs @@ -80,6 +80,9 @@ data FromClient = | Answer {accept :: Bool, to :: PlayerID} | Invitation {to :: PlayerID} | Play {move :: KoiKoi.Move, onGame :: PublicGame} + | Share {gameSave :: PublicGame} + | Sync {latestKnown :: Coordinates, to :: PlayerID} + | Yield {onGameID :: GameID, to :: PlayerID} | Quit | Ping deriving (Generic, Show) @@ -196,6 +199,7 @@ instance ToJSON ByteString where data PublicGame = PublicGame { nonce :: ByteString + , logs :: [KoiKoi.Action] , playerHand :: Hanafuda.Pack , private :: ByteString , public :: PublicState @@ -212,7 +216,7 @@ data T = | Okaeri {room :: Room} | LogIn {from :: PlayerID, as :: Text} | LogOut {from :: PlayerID} - | Game {state :: PublicGame, logs :: [KoiKoi.Action]} + | Game {state :: PublicGame} | Pong | Error {error :: String} deriving (Generic)