correctly calculate goalie average

This commit is contained in:
Jonathan Lamothe
2019-12-02 20:48:09 -05:00
parent d5ac42268f
commit 86c4fe316e
3 changed files with 20 additions and 8 deletions

View File

@@ -1010,4 +1010,10 @@ addGoalieStats g1 g2 = GoalieStats
-- | Determines a goalie's average goals allowed per game.
gsAverage :: GoalieStats -> Rational
gsAverage gs = fromIntegral (gs^.gsGoalsAllowed) / fromIntegral (gs^.gsGames)
gsAverage gs = let
allowed = fromIntegral $ gs^.gsGoalsAllowed
mins = fromIntegral $ gs^.gsMinsPlayed
gLen = fromIntegral gameLength
in if mins == 0
then 0
else allowed / mins * gLen