summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Player.hs16
1 files changed, 15 insertions, 1 deletions
diff --git a/Player.hs b/Player.hs
index 8a2adb6..ec0dbcc 100644
--- a/Player.hs
+++ b/Player.hs
@@ -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