mtlstats/src/Mtlstats/Helpers/Goalie.hs

63 lines
1.7 KiB
Haskell
Raw Normal View History

2019-11-20 22:00:58 -05:00
{- |
mtlstats
Copyright (C) 1984, 1985, 2019, 2020, 2021 Rhéal Lamothe
2019-11-20 22:00:58 -05:00
<rheal.lamothe@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-}
2020-01-04 11:02:58 -05:00
module Mtlstats.Helpers.Goalie (goalieDetails, goalieName) where
2019-11-20 22:00:58 -05:00
import Lens.Micro ((^.))
import Mtlstats.Format
import Mtlstats.Types
-- | Provides a detailed 'String' describing a 'Goalie'
goalieDetails :: Goalie -> String
goalieDetails g = let
header = unlines $ labelTable
[ ( "Number", show $ g^.gNumber )
2020-01-08 23:54:16 -05:00
, ( "Name", goalieName g )
2019-11-20 22:00:58 -05:00
]
body = unlines $ numTable ["YTD", "Lifetime"] $ map
(\(label, lens) -> (label, [g^.gYtd.lens, g^.gLifetime.lens]))
[ ( "Games played", gsGames )
, ( "Mins played", gsMinsPlayed )
, ( "Goals allowed", gsGoalsAllowed )
2020-01-02 00:42:04 -05:00
, ( "Shutouts", gsShutouts )
2019-11-20 22:00:58 -05:00
, ( "Wins", gsWins )
, ( "Losses", gsLosses )
, ( "Ties", gsTies )
]
in header ++ "\n" ++ body
2020-01-04 11:02:58 -05:00
-- | Returns the goalie name, modified if they are a rookie
goalieName :: Goalie -> String
goalieName g = let
2020-01-11 01:46:40 -05:00
prefix = if g^.gActive
then ""
else "*"
2020-01-04 11:02:58 -05:00
suffix = if g^.gRookie
then "*"
else ""
2020-01-11 01:46:40 -05:00
in prefix ++ g^.gName ++ suffix