commit
eb3714c40a
|
@ -1,5 +1,8 @@
|
||||||
# Changelog for mtlstats
|
# Changelog for mtlstats
|
||||||
|
|
||||||
|
## current
|
||||||
|
- allow ties
|
||||||
|
|
||||||
## 0.15.1
|
## 0.15.1
|
||||||
- only search for active players/goalies on game data input
|
- only search for active players/goalies on game data input
|
||||||
|
|
||||||
|
|
|
@ -43,9 +43,7 @@ import Mtlstats.Util
|
||||||
overtimeCheck :: ProgState -> ProgState
|
overtimeCheck :: ProgState -> ProgState
|
||||||
overtimeCheck s
|
overtimeCheck s
|
||||||
| fromMaybe False $ gameTied $ s^.progMode.gameStateL =
|
| fromMaybe False $ gameTied $ s^.progMode.gameStateL =
|
||||||
s & progMode.gameStateL
|
s & progMode.gameStateL.overtimeFlag ?~ True
|
||||||
%~ (homeScore .~ Nothing)
|
|
||||||
. (awayScore .~ Nothing)
|
|
||||||
| fromMaybe False $ gameWon $ s^.progMode.gameStateL =
|
| fromMaybe False $ gameWon $ s^.progMode.gameStateL =
|
||||||
s & progMode.gameStateL.overtimeFlag ?~ False
|
s & progMode.gameStateL.overtimeFlag ?~ False
|
||||||
| otherwise = s
|
| otherwise = s
|
||||||
|
|
|
@ -48,61 +48,31 @@ spec = describe "NewGame" $ do
|
||||||
GoalieInput.spec
|
GoalieInput.spec
|
||||||
|
|
||||||
overtimeCheckSpec :: Spec
|
overtimeCheckSpec :: Spec
|
||||||
overtimeCheckSpec = describe "overtimeCheck" $ do
|
overtimeCheckSpec = describe "overtimeCheck" $ mapM_
|
||||||
|
(\(label, expectation, gt, home, away, otf) ->
|
||||||
|
context label $
|
||||||
|
it expectation $ let
|
||||||
|
ps = newProgState & progMode.gameStateL
|
||||||
|
%~ (gameType ?~ gt)
|
||||||
|
. (homeScore ?~ home)
|
||||||
|
. (awayScore ?~ away)
|
||||||
|
|
||||||
context "tie game" $ do
|
ps' = overtimeCheck ps
|
||||||
let
|
in ps'^.progMode.gameStateL.overtimeFlag `shouldBe` otf)
|
||||||
s = newProgState
|
|
||||||
& progMode.gameStateL
|
|
||||||
%~ (gameType ?~ HomeGame)
|
|
||||||
. (homeScore ?~ 1)
|
|
||||||
. (awayScore ?~ 1)
|
|
||||||
& overtimeCheck
|
|
||||||
|
|
||||||
it "should clear the home score" $
|
-- label, expectation, type, home, away, ot flag
|
||||||
s^.progMode.gameStateL.homeScore `shouldBe` Nothing
|
[ ( "home win", clearFlag, HomeGame, 2, 1, Just False )
|
||||||
|
, ( "home loss", leaveFlag, HomeGame, 1, 2, Nothing )
|
||||||
|
, ( "home tie", setFlag, HomeGame, 1, 1, Just True )
|
||||||
|
, ( "away win", clearFlag, AwayGame, 1, 2, Just False )
|
||||||
|
, ( "away loss", leaveFlag, AwayGame, 2, 1, Nothing )
|
||||||
|
, ( "away tie", setFlag, AwayGame, 1, 1, Just True )
|
||||||
|
]
|
||||||
|
|
||||||
it "should clear the away score" $
|
where
|
||||||
s^.progMode.gameStateL.awayScore `shouldBe` Nothing
|
clearFlag = "should set the overtimeFlag to True"
|
||||||
|
setFlag = "should set the overtimeFlag to False"
|
||||||
it "should leave the overtimeFlag blank" $
|
leaveFlag = "should leave the overtimeFlag as Nothing"
|
||||||
s^.progMode.gameStateL.overtimeFlag `shouldBe` Nothing
|
|
||||||
|
|
||||||
context "game won" $ do
|
|
||||||
let
|
|
||||||
s = newProgState
|
|
||||||
& progMode.gameStateL
|
|
||||||
%~ (gameType ?~ HomeGame)
|
|
||||||
. (homeScore ?~ 2)
|
|
||||||
. (awayScore ?~ 1)
|
|
||||||
& overtimeCheck
|
|
||||||
|
|
||||||
it "should not change the home score" $
|
|
||||||
s^.progMode.gameStateL.homeScore `shouldBe` Just 2
|
|
||||||
|
|
||||||
it "should not change the away score" $
|
|
||||||
s^.progMode.gameStateL.awayScore `shouldBe` Just 1
|
|
||||||
|
|
||||||
it "should set the overtimeCheck flag to False" $
|
|
||||||
s^.progMode.gameStateL.overtimeFlag `shouldBe` Just False
|
|
||||||
|
|
||||||
context "game lost" $ do
|
|
||||||
let
|
|
||||||
s = newProgState
|
|
||||||
& progMode.gameStateL
|
|
||||||
%~ (gameType ?~ HomeGame)
|
|
||||||
. (homeScore ?~ 1)
|
|
||||||
. (awayScore ?~ 2)
|
|
||||||
& overtimeCheck
|
|
||||||
|
|
||||||
it "should not change the home score" $
|
|
||||||
s^.progMode.gameStateL.homeScore `shouldBe` Just 1
|
|
||||||
|
|
||||||
it "should not change the away score" $
|
|
||||||
s^.progMode.gameStateL.awayScore `shouldBe` Just 2
|
|
||||||
|
|
||||||
it "should leave the overtimeCheck flag blank" $
|
|
||||||
s^.progMode.gameStateL.overtimeFlag `shouldBe` Nothing
|
|
||||||
|
|
||||||
updateGameStatsSpec :: Spec
|
updateGameStatsSpec :: Spec
|
||||||
updateGameStatsSpec = describe "updateGameStats" $ do
|
updateGameStatsSpec = describe "updateGameStats" $ do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user