diff --git a/ChangeLog.md b/ChangeLog.md index 39090ea..c4b542a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -5,6 +5,7 @@ - Fixed player/goalie name capitalisation on edit - Return to correct edit menus after editing player stats - Enabled batch editing of player/goalie YTD/lifetime stats +- Bugfix: allow user to edit goalie shutouts ## 0.9.0 - Bugfix: Display lifetime stats in report, not YTD diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index 0db94fd..6e95895 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -46,23 +46,25 @@ selectC = promptController goalieToEditPrompt editC :: EditGoalieMode -> Controller editC = \case - EGMenu -> menuC - EGNumber -> numberC - EGName -> nameC - EGYtd -> ytdMenuC - EGLifetime -> lifetimeMenuC - EGYtdGames b -> ytdGamesC b - EGYtdMins b -> ytdMinsC b - EGYtdGoals b -> ytdGoalsC b - EGYtdWins b -> ytdWinsC b - EGYtdLosses b -> ytdLossesC b - EGYtdTies -> ytdTiesC - EGLtGames b -> ltGamesC b - EGLtMins b -> ltMinsC b - EGLtGoals b -> ltGoalsC b - EGLtWins b -> ltWinsC b - EGLtLosses b -> ltLossesC b - EGLtTies -> ltTiesC + EGMenu -> menuC + EGNumber -> numberC + EGName -> nameC + EGYtd -> ytdMenuC + EGLifetime -> lifetimeMenuC + EGYtdGames b -> ytdGamesC b + EGYtdMins b -> ytdMinsC b + EGYtdGoals b -> ytdGoalsC b + EGYtdShutouts b -> ytdShutoutsC b + EGYtdWins b -> ytdWinsC b + EGYtdLosses b -> ytdLossesC b + EGYtdTies -> ytdTiesC + EGLtGames b -> ltGamesC b + EGLtMins b -> ltMinsC b + EGLtGoals b -> ltGoalsC b + EGLtShutouts b -> ltShutoutsC b + EGLtWins b -> ltWinsC b + EGLtLosses b -> ltLossesC b + EGLtTies -> ltTiesC menuC :: Controller menuC = menuControllerWith header editGoalieMenu @@ -88,6 +90,9 @@ ytdMinsC = promptController . editGoalieYtdMinsPrompt ytdGoalsC :: Bool -> Controller ytdGoalsC = promptController . editGoalieYtdGoalsPrompt +ytdShutoutsC :: Bool -> Controller +ytdShutoutsC = promptController . editGoalieYtdShutoutsPrompt + ytdWinsC :: Bool -> Controller ytdWinsC = promptController . editGoalieYtdWinsPrompt @@ -106,6 +111,9 @@ ltMinsC = promptController . editGoalieLtMinsPrompt ltGoalsC :: Bool -> Controller ltGoalsC = promptController . editGoalieLtGoalsPrompt +ltShutoutsC :: Bool -> Controller +ltShutoutsC = promptController . editGoalieLtShutoutsPrompt + ltWinsC :: Bool -> Controller ltWinsC = promptController . editGoalieLtWinsPrompt diff --git a/src/Mtlstats/Helpers/Goalie.hs b/src/Mtlstats/Helpers/Goalie.hs index 0b760ed..38a777c 100644 --- a/src/Mtlstats/Helpers/Goalie.hs +++ b/src/Mtlstats/Helpers/Goalie.hs @@ -39,6 +39,7 @@ goalieDetails g = let [ ( "Games played", gsGames ) , ( "Mins played", gsMinsPlayed ) , ( "Goals allowed", gsGoalsAllowed ) + , ( "Shutouts", gsShutouts ) , ( "Wins", gsWins ) , ( "Losses", gsLosses ) , ( "Ties", gsTies ) diff --git a/src/Mtlstats/Menu/EditGoalie.hs b/src/Mtlstats/Menu/EditGoalie.hs index f9daf1e..812cf22 100644 --- a/src/Mtlstats/Menu/EditGoalie.hs +++ b/src/Mtlstats/Menu/EditGoalie.hs @@ -51,14 +51,15 @@ editGoalieMenu = Menu "*** EDIT GOALTENDER ***" () $ map editGoalieYtdMenu :: Menu () editGoalieYtdMenu = editMenu "*** EDIT GOALTENDER YEAR-TO-DATE ***" -- key, label, value - [ ( '1', "Edit all YTD stats", EGYtdGames True ) - , ( '2', "Edit YTD games", EGYtdGames False ) - , ( '3', "Edit YTD minutes", EGYtdMins False ) - , ( '4', "Edit YTD goals", EGYtdGoals False ) - , ( '5', "Edit YTD wins", EGYtdWins False ) - , ( '6', "Edit YTD losses", EGYtdLosses False ) - , ( '7', "Edit YTD ties", EGYtdTies ) - , ( 'R', "Return to edit menu", EGMenu ) + [ ( '1', "Edit all YTD stats", EGYtdGames True ) + , ( '2', "Edit YTD games", EGYtdGames False ) + , ( '3', "Edit YTD minutes", EGYtdMins False ) + , ( '4', "Edit YTD goals", EGYtdGoals False ) + , ( '5', "Edit YTD shutouts", EGYtdShutouts False ) + , ( '6', "Edit YTD wins", EGYtdWins False ) + , ( '7', "Edit YTD losses", EGYtdLosses False ) + , ( '8', "Edit YTD ties", EGYtdTies ) + , ( 'R', "Return to edit menu", EGMenu ) ] -- | The 'Goalie' lifetime edit menu @@ -66,14 +67,15 @@ editGoalieLtMenu :: Menu () editGoalieLtMenu = editMenu "*** EDIT GOALTENDER LIFETIME ***" -- key, label, value - [ ( '1', "Edit all lifetime stats", EGLtGames True ) - , ( '2', "Edit lifetime games", EGLtGames False ) - , ( '3', "Edit lifetime minutes", EGLtMins False ) - , ( '4', "Edit lifetime goals", EGLtGoals False ) - , ( '5', "Edit lifetime wins", EGLtWins False ) - , ( '6', "Edit lifetime losses", EGLtLosses False ) - , ( '7', "Edit lifetime ties", EGLtTies ) - , ( 'R', "Return to edit menu", EGMenu ) + [ ( '1', "Edit all lifetime stats", EGLtGames True ) + , ( '2', "Edit lifetime games", EGLtGames False ) + , ( '3', "Edit lifetime minutes", EGLtMins False ) + , ( '4', "Edit lifetime goals", EGLtGoals False ) + , ( '5', "Edit lifetime shutouts", EGLtShutouts False ) + , ( '6', "Edit lifetime wins", EGLtWins False ) + , ( '7', "Edit lifetime losses", EGLtLosses False ) + , ( '8', "Edit lifetime ties", EGLtTies ) + , ( 'R', "Return to edit menu", EGMenu ) ] editMenu :: String -> [(Char, String, EditGoalieMode)] -> Menu () diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index a5da5c6..5dbca9c 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -26,12 +26,14 @@ module Mtlstats.Prompt.EditGoalie , editGoalieYtdGamesPrompt , editGoalieYtdMinsPrompt , editGoalieYtdGoalsPrompt + , editGoalieYtdShutoutsPrompt , editGoalieYtdWinsPrompt , editGoalieYtdLossesPrompt , editGoalieYtdTiesPrompt , editGoalieLtGamesPrompt , editGoalieLtMinsPrompt , editGoalieLtGoalsPrompt + , editGoalieLtShutoutsPrompt , editGoalieLtWinsPrompt , editGoalieLtLossesPrompt , editGoalieLtTiesPrompt @@ -92,6 +94,17 @@ editGoalieYtdGoalsPrompt editGoalieYtdGoalsPrompt batchMode = editNum "Year-to-date goals allowed: " mode (gYtd.gsGoalsAllowed .~) + where + mode = if batchMode then EGYtdShutouts True else EGYtd + +-- | Prompt to edit a goalie's YTD shutouts +editGoalieYtdShutoutsPrompt + :: Bool + -- ^ Indicates whether or not we're in batch mode + -> Prompt +editGoalieYtdShutoutsPrompt batchMode = + editNum "Year-to-date shutouts: " mode + (gYtd.gsShutouts .~) where mode = if batchMode then EGYtdWins True else EGYtd @@ -152,6 +165,17 @@ editGoalieLtGoalsPrompt editGoalieLtGoalsPrompt batchMode = editNum "Lifetime goals allowed: " mode (gLifetime.gsGoalsAllowed .~) + where + mode = if batchMode then EGLtShutouts True else EGLifetime + +-- | Prompt to edit a goalie's lifetime shutouts +editGoalieLtShutoutsPrompt + :: Bool + -- ^ Indicates whether or not we're in batch mode + -> Prompt +editGoalieLtShutoutsPrompt batchMode = + editNum "Lifetime shutouts: " mode + (gLifetime.gsShutouts .~) where mode = if batchMode then EGLtWins True else EGLifetime diff --git a/src/Mtlstats/Types.hs b/src/Mtlstats/Types.hs index 62c6098..c996e42 100644 --- a/src/Mtlstats/Types.hs +++ b/src/Mtlstats/Types.hs @@ -369,17 +369,19 @@ data EditGoalieMode | EGName | EGYtd | EGLifetime - | EGYtdGames Bool - | EGYtdMins Bool - | EGYtdGoals Bool - | EGYtdWins Bool - | EGYtdLosses Bool + | EGYtdGames Bool + | EGYtdMins Bool + | EGYtdGoals Bool + | EGYtdShutouts Bool + | EGYtdWins Bool + | EGYtdLosses Bool | EGYtdTies - | EGLtGames Bool - | EGLtMins Bool - | EGLtGoals Bool - | EGLtWins Bool - | EGLtLosses Bool + | EGLtGames Bool + | EGLtMins Bool + | EGLtGoals Bool + | EGLtShutouts Bool + | EGLtWins Bool + | EGLtLosses Bool | EGLtTies deriving (Eq, Show) diff --git a/test/Helpers/GoalieSpec.hs b/test/Helpers/GoalieSpec.hs index af8a0c2..2c8ca25 100644 --- a/test/Helpers/GoalieSpec.hs +++ b/test/Helpers/GoalieSpec.hs @@ -38,28 +38,31 @@ goalieDetailsSpec = describe "goalieDetails" $ let %~ ( gsGames .~ 2 ) . ( gsMinsPlayed .~ 3 ) . ( gsGoalsAllowed .~ 4 ) - . ( gsWins .~ 5 ) - . ( gsLosses .~ 6 ) - . ( gsTies .~ 7 ) + . ( gsShutouts .~ 5 ) + . ( gsWins .~ 6 ) + . ( gsLosses .~ 7 ) + . ( gsTies .~ 8 ) & gLifetime - %~ ( gsGames .~ 8 ) - . ( gsMinsPlayed .~ 9 ) - . ( gsGoalsAllowed .~ 10 ) - . ( gsWins .~ 11 ) - . ( gsLosses .~ 12 ) - . ( gsTies .~ 13 ) + %~ ( gsGames .~ 9 ) + . ( gsMinsPlayed .~ 10 ) + . ( gsGoalsAllowed .~ 11 ) + . ( gsShutouts .~ 12 ) + . ( gsWins .~ 13 ) + . ( gsLosses .~ 14 ) + . ( gsTies .~ 15 ) expected = unlines [ "Number: 1" , " Name: Joe" , "" , " YTD Lifetime" - , " Games played 2 8" - , " Mins played 3 9" - , "Goals allowed 4 10" - , " Wins 5 11" - , " Losses 6 12" - , " Ties 7 13" + , " Games played 2 9" + , " Mins played 3 10" + , "Goals allowed 4 11" + , " Shutouts 5 12" + , " Wins 6 13" + , " Losses 7 14" + , " Ties 8 15" ] in it "should format the output correctly" $