diff options
author | Frederick Yin <fkfd@fkfd.me> | 2023-01-07 20:29:29 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2023-01-07 20:29:29 +0800 |
commit | 81ea0f259a49d1a66374afe747334d96eee34b6a (patch) | |
tree | 033eb983ed84d54e542c0930942a84a9874ccc39 /Card.hs | |
parent | ba61f2b7363116f6530fc6c256b1ad97ef0e0861 (diff) |
Card.isSpecial and isValid
Diffstat (limited to 'Card.hs')
-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') |