diff --git a/src/Mtlstats/Format.hs b/src/Mtlstats/Format.hs index b7a1a06..e89fdf9 100644 --- a/src/Mtlstats/Format.hs +++ b/src/Mtlstats/Format.hs @@ -33,6 +33,7 @@ module Mtlstats.Format , tableWith , complexTable , overlayLast + , showFloating ) where import Data.List (transpose) @@ -185,3 +186,7 @@ overlayLast overlayLast _ [] = [] overlayLast str [l] = [overlay str l] overlayLast str (l:ls) = l : overlayLast str ls + +-- | Converts a non-integer into a string +showFloating :: Fractional n => n -> String +showFloating = undefined diff --git a/src/Mtlstats/Report.hs b/src/Mtlstats/Report.hs index 98bc9d6..913e2c8 100644 --- a/src/Mtlstats/Report.hs +++ b/src/Mtlstats/Report.hs @@ -213,4 +213,44 @@ playerReport width label ps = let in rHeader ++ table goalieReport :: Int -> [(Goalie, GoalieStats)] -> [String] -goalieReport = undefined +goalieReport width goalieData = let + olayText = "GOALTENDING TOTALS" + + tData = foldl addGoalieStats newGoalieStats + $ map snd goalieData + + header = + [ CellText "NO." + , CellText $ left (length olayText) "GOALTENDER" + , CellText "GP" + , CellText " MIN" + , CellText " GA" + , CellText " SO" + , CellText "AVE" + ] + + rowCells stats = + [ CellText $ show $ stats^.gsGames + , CellText $ show $ stats^.gsMinsPlayed + , CellText $ show $ stats^.gsGoalsAllowed + , CellText $ show $ stats^.gsShutouts + , CellText $ showFloating $ gsAverage stats + ] + + body = map + (\(goalie, stats) -> + [ CellText $ show (goalie^.gNumber) ++ " " + , CellText $ show $ goalie^.gName + ] ++ rowCells stats) + goalieData + + separator + = replicate 2 (CellText "") + ++ replicate 5 (CellFill '-') + + summary = replicate 2 (CellText "") ++ rowCells tData + + in map (centre width) + $ overlayLast olayText + $ complexTable ([right, left] ++ repeat right) + $ header : body ++ [separator, summary] diff --git a/src/Mtlstats/Types.hs b/src/Mtlstats/Types.hs index 4cc65a1..1c7849e 100644 --- a/src/Mtlstats/Types.hs +++ b/src/Mtlstats/Types.hs @@ -171,7 +171,10 @@ module Mtlstats.Types ( goalieSearch, goalieSearchExact, goalieSummary, - goalieIsActive + goalieIsActive, + -- ** GoalieStats Helpers + addGoalieStats, + gsAverage ) where import Control.Monad.Trans.State (StateT) @@ -990,3 +993,11 @@ goalieSummary g = g^.gName ++ " (" ++ show (g^.gNumber) ++ ")" -- season goalieIsActive :: Goalie -> Bool goalieIsActive g = g^.gYtd.gsMinsPlayed /= 0 + +-- | Adds two sets of 'GoalieStats' +addGoalieStats :: GoalieStats -> GoalieStats -> GoalieStats +addGoalieStats = undefined + +-- | Determines a goalie's average goals allowed per game. +gsAverage :: GoalieStats -> Rational +gsAverage = undefined