summaryrefslogtreecommitdiff
path: root/Player.hs
blob: ec0dbcc77d9b2ba81ac359730370300a8605f384 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module Player where

import qualified Data.List as L
import Card (Card)
import qualified Card as C

data Player = Player { name :: String
                     , penalty :: Integer
                     , cards :: [Card]
                     }

-- | Same player after shedding card specified.
shed :: Player -> Card -> Player
shed (Player n p cs) c = Player n p $ L.delete c cs

-- | Same player after drawing card specified.
draw :: Player -> Card -> Player
draw (Player n p cs) c = Player n p $ L.sort (c:cs)

-- | Show player's cards, e.g. "1. Spade 2"
showCards :: Player -> String
showCards (Player _ _ cs) =
    unlines $ zipWith (\i c -> (show i) ++ ". " ++ C.showCard c) [1..] cs