Implement a partial ordering on game coordinates to allow implementing re-synchronization easily
This commit is contained in:
parent
59c467e988
commit
e2019e2d3b
1 changed files with 8 additions and 0 deletions
|
@ -13,6 +13,7 @@ module Hanafuda.Message (
|
|||
, PublicPlayer(..)
|
||||
, PublicState(..)
|
||||
, Room
|
||||
, orderCoordinates
|
||||
) where
|
||||
|
||||
import Data.Char (toLower)
|
||||
|
@ -153,6 +154,13 @@ instance FromJSON Coordinates
|
|||
instance ToJSON Coordinates where
|
||||
toEncoding = genericToEncoding defaultOptions
|
||||
|
||||
orderCoordinates :: Coordinates -> Coordinates -> Maybe Ordering
|
||||
orderCoordinates coordinatesA coordinatesB
|
||||
| gameID coordinatesA == gameID coordinatesB = Just $ compare
|
||||
(month coordinatesA, turn coordinatesA)
|
||||
(month coordinatesB, turn coordinatesB)
|
||||
| otherwise = Nothing
|
||||
|
||||
data PrivateState = PrivateState {
|
||||
link :: Coordinates
|
||||
, hands :: Map PlayerID Hanafuda.Pack
|
||||
|
|
Loading…
Reference in a new issue