Generalize GameState into a concept of game Coordinates, moving the «month» property into it

This commit is contained in:
Tissevert 2020-01-18 09:34:10 +01:00
parent 509a5c453f
commit 4c404df4d6
1 changed files with 8 additions and 8 deletions

View File

@ -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