diff options
author | Frederick Yin <fkfd@fkfd.me> | 2023-01-08 21:48:32 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2023-01-08 21:48:32 +0800 |
commit | 347cee5089d0d0d3300fa4cfc1ec1181e179ee2b (patch) | |
tree | c2e82e8f05adbec18d099a5dc52618f93dad8a75 /Card.hs | |
parent | 63c6921b102b5b97bc3d030b22fc941c64c0acd2 (diff) |
Force special card after attack cards only
Diffstat (limited to 'Card.hs')
-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') |