don't mark goalies recorded unless at least one has been entered
This commit is contained in:
parent
b0cf9a83a1
commit
3f38160abd
|
@ -37,6 +37,7 @@ module Mtlstats.Actions
|
|||
, addGoalie
|
||||
, resetCreatePlayerState
|
||||
, resetCreateGoalieState
|
||||
, finishGameGoalieEntry
|
||||
, recordGoalAssists
|
||||
, awardGoal
|
||||
, awardAssist
|
||||
|
@ -200,6 +201,11 @@ resetCreateGoalieState = progMode.createGoalieStateL
|
|||
%~ (cgsNumber .~ Nothing)
|
||||
. (cgsName .~ "")
|
||||
|
||||
-- | Attempts to finish game goalie entry
|
||||
finishGameGoalieEntry :: ProgState -> ProgState
|
||||
finishGameGoalieEntry s = s & progMode.gameStateL.goaliesRecorded
|
||||
.~ not (null $ s^.progMode.gameStateL.gameGoalieStats)
|
||||
|
||||
-- | Awards the goal and assists to the players
|
||||
recordGoalAssists :: ProgState -> ProgState
|
||||
recordGoalAssists ps = fromMaybe ps $ do
|
||||
|
|
|
@ -338,7 +338,7 @@ goalieNamePrompt = strPrompt "Goalie name: " $
|
|||
selectGameGoaliePrompt :: Prompt
|
||||
selectGameGoaliePrompt = selectGoaliePrompt "Which goalie played this game: " $
|
||||
\case
|
||||
Nothing -> modify $ progMode.gameStateL.goaliesRecorded .~ True
|
||||
Nothing -> modify finishGameGoalieEntry
|
||||
Just n -> modify $ progMode.gameStateL.gameSelectedGoalie ?~ n
|
||||
|
||||
-- | Prompts for the number of minutes the goalie has played
|
||||
|
|
|
@ -62,6 +62,7 @@ spec = describe "Mtlstats.Actions" $ do
|
|||
addGoalieSpec
|
||||
resetCreatePlayerStateSpec
|
||||
resetCreateGoalieStateSpec
|
||||
finishGameGoalieEntrySpec
|
||||
recordGoalAssistsSpec
|
||||
awardGoalSpec
|
||||
awardAssistSpec
|
||||
|
@ -439,6 +440,23 @@ resetCreateGoalieStateSpec = describe "resetCreateGoalieState" $ let
|
|||
newProgState & progMode.createGoalieStateL .~ cgs
|
||||
in TS.compareTest (ps^.progMode.createGoalieStateL) newCreateGoalieState
|
||||
|
||||
finishGameGoalieEntrySpec :: Spec
|
||||
finishGameGoalieEntrySpec = describe "finishGameGoalieEntry" $ do
|
||||
let
|
||||
progState stats = newProgState
|
||||
& progMode.gameStateL.gameGoalieStats .~ stats
|
||||
& finishGameGoalieEntry
|
||||
|
||||
context "no goalie data" $
|
||||
it "should not set goaliesRecorded" $ let
|
||||
s = progState M.empty
|
||||
in s^.progMode.gameStateL.goaliesRecorded `shouldBe` False
|
||||
|
||||
context "goalie data" $
|
||||
it "should set goaliesRecorded" $ let
|
||||
s = progState $ M.fromList [(1, newGoalieStats)]
|
||||
in s^.progMode.gameStateL.goaliesRecorded `shouldBe` True
|
||||
|
||||
recordGoalAssistsSpec :: Spec
|
||||
recordGoalAssistsSpec = describe "recordGoalAssists" $ do
|
||||
let
|
||||
|
|
Loading…
Reference in New Issue
Block a user