diff --git a/src/Skat/Preperation.hs b/src/Skat/Preperation.hs index 11a16e5..4220bb3 100644 --- a/src/Skat/Preperation.hs +++ b/src/Skat/Preperation.hs @@ -93,11 +93,16 @@ initGame single bid = do -- ask if player wants to play hand noSkat <- askHand (bidder bds single) bid -- either return piles or ask for skat cards and modify piles - ps' <- if noSkat then return ps else do - let skat = skatCards ps - skat' <- askSkat (bidder bds single) bid skat - return $ moveToSkat single skat' ps + ps' <- if noSkat then return ps else handleSkat (bidder bds single) bid ps -- ask for game kind (Colour col _) <- askGame (bidder bds single) bid -- construct skat env return $ mkSkatEnv ps Nothing col (toPlayers single bds) Hand1 + +handleSkat :: BD -> Bid -> Piles -> Preperation Piles +handleSkat bd bid ps = do + let skat = skatCards ps + skat' <- askSkat bd bid skat + case moveToSkat (hand bd) skat' ps of + Just correct -> return correct + Nothing -> handleSkat bd bid ps