From 4c404df4d60016a07bc2bac864baee65394d3f7a Mon Sep 17 00:00:00 2001 From: Tissevert Date: Sat, 18 Jan 2020 09:34:10 +0100 Subject: [PATCH] =?UTF-8?q?Generalize=20GameState=20into=20a=20concept=20o?= =?UTF-8?q?f=20game=20Coordinates,=20moving=20the=20=C2=ABmonth=C2=BB=20pr?= =?UTF-8?q?operty=20into=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Hanafuda/Message.hs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Hanafuda/Message.hs b/src/Hanafuda/Message.hs index dc01dcd..8dd83cc 100644 --- a/src/Hanafuda/Message.hs +++ b/src/Hanafuda/Message.hs @@ -7,7 +7,7 @@ module Hanafuda.Message ( T(..) , FromClient(..) - , GameState(..) + , Coordinates(..) , PrivateState(..) , PublicGame(..) , PublicPlayer(..) @@ -140,17 +140,18 @@ instance FromJSON Hanafuda.Flower instance ToJSON Hanafuda.Flower where toEncoding = genericToEncoding defaultOptions -data GameState = GameState { +data Coordinates = Coordinates { gameID :: GameID - , turns :: Int + , month :: Hanafuda.Flower + , turn :: Int } deriving (Eq, Generic, Show) -instance FromJSON GameState -instance ToJSON GameState where +instance FromJSON Coordinates +instance ToJSON Coordinates where toEncoding = genericToEncoding defaultOptions data PrivateState = PrivateState { - link :: GameState + link :: Coordinates , hands :: Map PlayerID Hanafuda.Pack , deck :: [Hanafuda.Card] } deriving Generic @@ -169,10 +170,9 @@ instance ToJSON PublicPlayer where toEncoding = genericToEncoding defaultOptions data PublicState = PublicState { - gameState :: GameState + coordinates :: Coordinates , mode :: KoiKoi.Mode , scores :: KoiKoi.Scores - , month :: Hanafuda.Flower , nextPlayer :: KoiKoi.PlayerTurn , players :: Map PlayerID PublicPlayer , playing :: PlayerID