Generalize GameState into a concept of game Coordinates, moving the «month» property into it
This commit is contained in:
parent
509a5c453f
commit
4c404df4d6
1 changed files with 8 additions and 8 deletions
|
@ -7,7 +7,7 @@
|
||||||
module Hanafuda.Message (
|
module Hanafuda.Message (
|
||||||
T(..)
|
T(..)
|
||||||
, FromClient(..)
|
, FromClient(..)
|
||||||
, GameState(..)
|
, Coordinates(..)
|
||||||
, PrivateState(..)
|
, PrivateState(..)
|
||||||
, PublicGame(..)
|
, PublicGame(..)
|
||||||
, PublicPlayer(..)
|
, PublicPlayer(..)
|
||||||
|
@ -140,17 +140,18 @@ instance FromJSON Hanafuda.Flower
|
||||||
instance ToJSON Hanafuda.Flower where
|
instance ToJSON Hanafuda.Flower where
|
||||||
toEncoding = genericToEncoding defaultOptions
|
toEncoding = genericToEncoding defaultOptions
|
||||||
|
|
||||||
data GameState = GameState {
|
data Coordinates = Coordinates {
|
||||||
gameID :: GameID
|
gameID :: GameID
|
||||||
, turns :: Int
|
, month :: Hanafuda.Flower
|
||||||
|
, turn :: Int
|
||||||
} deriving (Eq, Generic, Show)
|
} deriving (Eq, Generic, Show)
|
||||||
|
|
||||||
instance FromJSON GameState
|
instance FromJSON Coordinates
|
||||||
instance ToJSON GameState where
|
instance ToJSON Coordinates where
|
||||||
toEncoding = genericToEncoding defaultOptions
|
toEncoding = genericToEncoding defaultOptions
|
||||||
|
|
||||||
data PrivateState = PrivateState {
|
data PrivateState = PrivateState {
|
||||||
link :: GameState
|
link :: Coordinates
|
||||||
, hands :: Map PlayerID Hanafuda.Pack
|
, hands :: Map PlayerID Hanafuda.Pack
|
||||||
, deck :: [Hanafuda.Card]
|
, deck :: [Hanafuda.Card]
|
||||||
} deriving Generic
|
} deriving Generic
|
||||||
|
@ -169,10 +170,9 @@ instance ToJSON PublicPlayer where
|
||||||
toEncoding = genericToEncoding defaultOptions
|
toEncoding = genericToEncoding defaultOptions
|
||||||
|
|
||||||
data PublicState = PublicState {
|
data PublicState = PublicState {
|
||||||
gameState :: GameState
|
coordinates :: Coordinates
|
||||||
, mode :: KoiKoi.Mode
|
, mode :: KoiKoi.Mode
|
||||||
, scores :: KoiKoi.Scores
|
, scores :: KoiKoi.Scores
|
||||||
, month :: Hanafuda.Flower
|
|
||||||
, nextPlayer :: KoiKoi.PlayerTurn
|
, nextPlayer :: KoiKoi.PlayerTurn
|
||||||
, players :: Map PlayerID PublicPlayer
|
, players :: Map PlayerID PublicPlayer
|
||||||
, playing :: PlayerID
|
, playing :: PlayerID
|
||||||
|
|
Loading…
Reference in a new issue