fix moveToSkat
This commit is contained in:
+10
-5
@@ -110,13 +110,18 @@ playCard :: HasCard c => Hand -> c -> Piles -> Piles
|
||||
playCard hand card' ps = (removeFromHand hand card ps) { _table = (CardS card (P hand)) : _table ps }
|
||||
where card = toCard card'
|
||||
|
||||
moveToSkat :: HasCard c => Hand -> [c] -> Piles -> Piles
|
||||
moveToSkat hand cards' piles = removed { _skat = newSkat }
|
||||
moveToSkat :: HasCard c => Hand -> [c] -> Piles -> Maybe Piles
|
||||
moveToSkat hand cards' piles
|
||||
| length cards' == 2 && all (`elem` possible) cards =
|
||||
Just $ updated { _skat = newSkat }
|
||||
| otherwise = Nothing
|
||||
where cards = map toCard cards'
|
||||
skat = skatCards piles
|
||||
notSkatYet = filter (not . (`elem` skat)) cards
|
||||
newSkat = map (putAt S) $ skat ++ notSkatYet
|
||||
oldSkat = skatCards piles
|
||||
noLongerSkat = filter (not . (`elem` cards)) oldSkat
|
||||
possible = map toCard (handCards hand piles) ++ oldSkat
|
||||
newSkat = map (putAt S) cards
|
||||
removed = foldr (\card ps -> removeFromHand hand card ps) piles cards
|
||||
updated = foldr (\card ps -> addToHand hand card ps) removed noLongerSkat
|
||||
|
||||
unplayCard :: Hand -> Card -> Team -> Piles -> Piles
|
||||
unplayCard hand card winner ps
|
||||
|
||||
Reference in New Issue
Block a user