diff options
-rw-r--r-- | Card.hs | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -47,8 +47,15 @@ isSpecial (Card _ rk) | rk `elem` [Two, Three, Seven, Jack, Queen] = True | otherwise = False +-- | Check if card attacks. +isAttack :: Card -> Bool +isAttack (Card _ rk) + | rk `elem` [Two, Three] = True + | otherwise = False + -- | Check if `card` is valid after `prev`. +-- | If `prev` attacks, `card` must be special. isValid :: Card -> Card -> Bool isValid prev@(Card st' rk') card@(Card st rk) = - match && (not (isSpecial prev) || isSpecial card) + match && (not (isAttack prev) || isSpecial card) where match = (st == st') || (rk == rk') |