serialization of piles
This commit is contained in:
@@ -40,6 +40,8 @@ class Bidder a where
|
||||
onGame _ _ _ = return ()
|
||||
onResult :: MonadIO m => a -> Result -> m ()
|
||||
onResult _ _ = return ()
|
||||
onNoGame :: MonadIO m => a -> m ()
|
||||
onNoGame _ = return ()
|
||||
|
||||
-- | trick to allow heterogenous bidder list
|
||||
data BD = forall b. (Show b, Bidder b) => BD b
|
||||
@@ -60,6 +62,7 @@ instance Bidder BD where
|
||||
onResult (BD b) = onResult b
|
||||
onBid (BD b) = onBid b
|
||||
onResponse (BD b) = onResponse b
|
||||
onNoGame (BD b) = onNoGame b
|
||||
|
||||
data Bidders = Bidders BD BD BD
|
||||
deriving Show
|
||||
@@ -88,7 +91,7 @@ runPreperation = do
|
||||
publishBid bid finalWinner finalWinner
|
||||
case bid of
|
||||
Just val -> (Just . (finalWinner,)) <$> initGame finalWinner val
|
||||
Nothing -> return Nothing
|
||||
Nothing -> publishNoGame >> return Nothing
|
||||
else (Just . (finalWinner,)) <$> initGame finalWinner finalBid
|
||||
|
||||
runBidding :: Bid -> BD -> BD -> Preperation (Hand, Bid)
|
||||
@@ -160,6 +163,9 @@ publishBid bid reizer gereizter = mapBidders (\b -> onBid b bid reizer gereizter
|
||||
publishResponse :: Bool -> Hand -> Hand -> Preperation ()
|
||||
publishResponse response reizer gereizter = mapBidders (\b -> onResponse b response reizer gereizter)
|
||||
|
||||
publishNoGame :: Preperation ()
|
||||
publishNoGame = mapBidders onNoGame
|
||||
|
||||
mapBidders :: (BD -> Preperation ()) -> Preperation ()
|
||||
mapBidders f = do
|
||||
bds <- asks bidders
|
||||
|
||||
Reference in New Issue
Block a user