diff options
-rw-r--r-- | Card.hs | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -35,3 +35,15 @@ shuffle gen xs = (head right):(shuffle newGen (left ++ (tail right))) where (rand, newGen) = random gen i = rand `mod` (length xs) (left, right) = splitAt i xs + +-- | Check if card is special. +isSpecial :: Card -> Bool +isSpecial (Card _ rk) + | rk `elem` [Two, Three, Seven, Jack, Queen] = True + | otherwise = False + +-- | Check if `card` is valid after `prev`. +isValid :: Card -> Card -> Bool +isValid prev@(Card st' rk') card@(Card st rk) = + match && (not (isSpecial prev) || isSpecial card) + where match = (st == st') || (rk == rk') |