changed teamScore to check GameState
This commit is contained in:
parent
13d422100b
commit
29459063c8
|
@ -93,7 +93,7 @@ module Mtlstats.Types (
|
|||
newGoalieStats,
|
||||
newGameStats,
|
||||
-- * Helper Functions
|
||||
-- ** ProgState Helpers
|
||||
-- ** GameState Helpers
|
||||
teamScore,
|
||||
-- ** Player Helpers
|
||||
pPoints
|
||||
|
@ -504,11 +504,11 @@ newGameStats = GameStats
|
|||
, _gmsOvertime = 0
|
||||
}
|
||||
|
||||
-- | Determines the team's points
|
||||
teamScore :: ProgState -> Maybe Int
|
||||
teamScore s = case s ^. progMode . gameTypeL of
|
||||
Just HomeGame -> s ^. progMode . homeScoreL
|
||||
Just AwayGame -> s ^. progMode . awayScoreL
|
||||
-- | Determines the team's score
|
||||
teamScore :: GameState -> Maybe Int
|
||||
teamScore s = case s ^. gameType of
|
||||
Just HomeGame -> s ^. homeScore
|
||||
Just AwayGame -> s ^. awayScore
|
||||
Nothing -> Nothing
|
||||
|
||||
-- | Calculates a player's points
|
||||
|
|
|
@ -197,16 +197,14 @@ awayScoreLSpec = describe "awayScoreL" $ do
|
|||
teamScoreSpec :: Spec
|
||||
teamScoreSpec = describe "teamScore" $ do
|
||||
let
|
||||
m t = NewGame $ newGameState
|
||||
s t = newGameState
|
||||
& gameType ?~ t
|
||||
& homeScore ?~ 1
|
||||
& awayScore ?~ 2
|
||||
s t = newProgState
|
||||
& progMode .~ m t
|
||||
|
||||
context "unexpected state" $
|
||||
context "unknown game type" $
|
||||
it "should return Nothing" $
|
||||
teamScore newProgState `shouldBe` Nothing
|
||||
teamScore newGameState `shouldBe` Nothing
|
||||
|
||||
context "HomeGame" $
|
||||
it "should return 1" $
|
||||
|
|
Loading…
Reference in New Issue
Block a user