Define a public type for players and keep only the player's hand in private information and public game
This commit is contained in:
parent
65a7c26b5a
commit
c4edae9781
1 changed files with 13 additions and 3 deletions
|
@ -142,14 +142,24 @@ instance ToJSON Hanafuda.Flower where
|
|||
toEncoding = genericToEncoding defaultOptions
|
||||
|
||||
data PrivateState = PrivateState {
|
||||
opponent :: Player KoiKoi.Score
|
||||
opponentHand :: Hanafuda.Pack
|
||||
, deck :: [Hanafuda.Card]
|
||||
} deriving Generic
|
||||
|
||||
data PublicPlayer = PublicPlayer {
|
||||
meld :: Hanafuda.Pack
|
||||
, yakus :: KoiKoi.Score
|
||||
} deriving Generic
|
||||
|
||||
instance FromJSON PublicPlayer
|
||||
instance ToJSON PublicPlayer where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
|
||||
data PublicState = PublicState {
|
||||
mode :: KoiKoi.Mode
|
||||
, scores :: Scores KoiKoi.Score
|
||||
, month :: Hanafuda.Flower
|
||||
, players :: Map PlayerID PublicPlayer
|
||||
, playing :: PlayerID
|
||||
, winning :: PlayerID
|
||||
, oyake :: PlayerID
|
||||
|
@ -170,7 +180,7 @@ instance ToJSON ByteString where
|
|||
toEncoding = toEncoding . decodeUtf8
|
||||
|
||||
data PublicGame = PublicGame {
|
||||
player :: Player KoiKoi.Score
|
||||
playerHand :: Hanafuda.Pack
|
||||
, privateState :: ByteString
|
||||
, publicState :: PublicState
|
||||
, publicSignature :: ByteString
|
||||
|
@ -184,7 +194,7 @@ data T =
|
|||
Relay {from :: PlayerID, message :: FromClient}
|
||||
| Welcome {room :: Room, key :: PlayerID}
|
||||
| Update {alone :: [PlayerID], paired :: [PlayerID]}
|
||||
| Game {game :: PublicGame, logs :: [KoiKoi.Action]}
|
||||
| Game {state :: PublicGame, logs :: [KoiKoi.Action]}
|
||||
| Pong
|
||||
| Error {error :: String}
|
||||
deriving (Generic)
|
||||
|
|
Loading…
Reference in a new issue