From 461fb5d9422528af4f3cfbd504ced85a3816971a Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Sat, 11 Jan 2020 01:27:01 -0500 Subject: [PATCH] mark inactive players in playerName --- src/Mtlstats/Helpers/Player.hs | 6 +++++- test/Helpers/PlayerSpec.hs | 10 +++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Mtlstats/Helpers/Player.hs b/src/Mtlstats/Helpers/Player.hs index e79813d..2e1ad5f 100644 --- a/src/Mtlstats/Helpers/Player.hs +++ b/src/Mtlstats/Helpers/Player.hs @@ -49,8 +49,12 @@ playerDetails p = unlines $ top ++ [""] ++ table playerName :: Player -> String playerName p = let + prefix = if p^.pActive + then "" + else "*" + suffix = if p^.pRookie then "*" else "" - in p^.pName ++ suffix + in prefix ++ p^.pName ++ suffix diff --git a/test/Helpers/PlayerSpec.hs b/test/Helpers/PlayerSpec.hs index 9896bd0..59f9436 100644 --- a/test/Helpers/PlayerSpec.hs +++ b/test/Helpers/PlayerSpec.hs @@ -71,9 +71,13 @@ playerNameSpec = describe "playerName" $ mapM_ -- label, player, expected [ ( "rookie", rookie, "foo*" ) , ( "non-rookie", nonRookie, "foo" ) + , ( "retired", retired, "*foo" ) ] where - rookie = player True - nonRookie = player False - player r = newPlayer 1 "foo" "centre" & pRookie .~ r + rookie = player True True + nonRookie = player False True + retired = player False False + player r a = newPlayer 1 "foo" "centre" + & pRookie .~ r + & pActive .~ a