implemented gmsPoints
This commit is contained in:
parent
4c13cc9103
commit
9e855d9672
|
@ -97,6 +97,8 @@ module Mtlstats.Types (
|
||||||
gameWon,
|
gameWon,
|
||||||
gameLost,
|
gameLost,
|
||||||
gameTied,
|
gameTied,
|
||||||
|
-- ** GameStats Helpers
|
||||||
|
gmsPoints,
|
||||||
-- ** Player Helpers
|
-- ** Player Helpers
|
||||||
pPoints
|
pPoints
|
||||||
) where
|
) where
|
||||||
|
@ -506,6 +508,10 @@ gameLost gs = (<) <$> teamScore gs <*> otherScore gs
|
||||||
gameTied :: GameState -> Maybe Bool
|
gameTied :: GameState -> Maybe Bool
|
||||||
gameTied gs = (==) <$> gs^.homeScore <*> gs^.awayScore
|
gameTied gs = (==) <$> gs^.homeScore <*> gs^.awayScore
|
||||||
|
|
||||||
|
-- | Calculates the number of points
|
||||||
|
gmsPoints :: GameStats -> Int
|
||||||
|
gmsPoints gs = 2 * gs^.gmsWins + gs^. gmsOvertime
|
||||||
|
|
||||||
-- | Calculates a player's points
|
-- | Calculates a player's points
|
||||||
pPoints :: PlayerStats -> Int
|
pPoints :: PlayerStats -> Int
|
||||||
pPoints s = s^.psGoals + s^.psAssists
|
pPoints s = s^.psGoals + s^.psAssists
|
||||||
|
|
|
@ -46,6 +46,7 @@ spec = describe "Mtlstats.Types" $ do
|
||||||
gameWonSpec
|
gameWonSpec
|
||||||
gameLostSpec
|
gameLostSpec
|
||||||
gameTiedSpec
|
gameTiedSpec
|
||||||
|
gmsPointsSpec
|
||||||
pPointsSpec
|
pPointsSpec
|
||||||
Menu.spec
|
Menu.spec
|
||||||
|
|
||||||
|
@ -320,6 +321,26 @@ gameTiedSpec = describe "gameTied" $ mapM_
|
||||||
, ( Just 1, Just 2, Just False )
|
, ( Just 1, Just 2, Just False )
|
||||||
]
|
]
|
||||||
|
|
||||||
|
gmsPointsSpec :: Spec
|
||||||
|
gmsPointsSpec = describe "gmsPoints" $ mapM_
|
||||||
|
(\(w, l, ot, expected) -> let
|
||||||
|
gs = GameStats
|
||||||
|
{ _gmsWins = w
|
||||||
|
, _gmsLosses = l
|
||||||
|
, _gmsOvertime = ot
|
||||||
|
}
|
||||||
|
in context (show gs) $
|
||||||
|
it ("should be " ++ show expected) $
|
||||||
|
gmsPoints gs `shouldBe` expected)
|
||||||
|
-- wins, losses, overtime, expected
|
||||||
|
[ ( 0, 0, 0, 0 )
|
||||||
|
, ( 1, 0, 0, 2 )
|
||||||
|
, ( 0, 1, 0, 0 )
|
||||||
|
, ( 0, 1, 1, 1 )
|
||||||
|
, ( 1, 1, 1, 3 )
|
||||||
|
, ( 2, 4, 3, 7 )
|
||||||
|
]
|
||||||
|
|
||||||
pPointsSpec :: Spec
|
pPointsSpec :: Spec
|
||||||
pPointsSpec = describe "pPoints" $ mapM_
|
pPointsSpec = describe "pPoints" $ mapM_
|
||||||
(\(goals, assists, points) -> let
|
(\(goals, assists, points) -> let
|
||||||
|
|
Loading…
Reference in New Issue
Block a user