summaryrefslogtreecommitdiff
path: root/Player.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Player.hs')
-rw-r--r--Player.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/Player.hs b/Player.hs
index 5aad025..ec4d180 100644
--- a/Player.hs
+++ b/Player.hs
@@ -6,7 +6,7 @@ import qualified Card as C
import qualified Color
data Player = Player { name :: String
- , penalty :: Integer
+ , penalty :: Int
, cards :: [Card]
}
@@ -35,3 +35,13 @@ showCards (Player _ _ cs) prev att =
else join n c
else Color.red $ join n c
join n c = (show n) ++ ". " ++ (C.showCard c)
+
+-- | Update penalty for each player after a round.
+calcPenalties :: [Player] -> [Player]
+calcPenalties plyrs = map penalize plyrs
+ where penalize (Player n p c) = Player n (p + length c) c
+
+-- | Pretty print penalties.
+showPenalties :: [Player] -> String
+showPenalties = unlines . map showPenalty
+ where showPenalty (Player n p _) = n ++ ":\t" ++ show p