diff options
-rw-r--r-- | Player.hs | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -1,9 +1,23 @@ module Player where +import qualified Data.List as L import Card (Card) -import qualified 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 |