summaryrefslogtreecommitdiff
path: root/Card.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Card.hs')
-rw-r--r--Card.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/Card.hs b/Card.hs
index 64c74c8..98e76fe 100644
--- a/Card.hs
+++ b/Card.hs
@@ -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')