allow user to edit goalie shutouts

This commit is contained in:
Jonathan Lamothe 2020-01-02 00:42:04 -05:00
parent 0448a4beee
commit aff1d5c255
7 changed files with 99 additions and 58 deletions

View File

@ -5,6 +5,7 @@
- Fixed player/goalie name capitalisation on edit - Fixed player/goalie name capitalisation on edit
- Return to correct edit menus after editing player stats - Return to correct edit menus after editing player stats
- Enabled batch editing of player/goalie YTD/lifetime stats - Enabled batch editing of player/goalie YTD/lifetime stats
- Bugfix: allow user to edit goalie shutouts
## 0.9.0 ## 0.9.0
- Bugfix: Display lifetime stats in report, not YTD - Bugfix: Display lifetime stats in report, not YTD

View File

@ -46,23 +46,25 @@ selectC = promptController goalieToEditPrompt
editC :: EditGoalieMode -> Controller editC :: EditGoalieMode -> Controller
editC = \case editC = \case
EGMenu -> menuC EGMenu -> menuC
EGNumber -> numberC EGNumber -> numberC
EGName -> nameC EGName -> nameC
EGYtd -> ytdMenuC EGYtd -> ytdMenuC
EGLifetime -> lifetimeMenuC EGLifetime -> lifetimeMenuC
EGYtdGames b -> ytdGamesC b EGYtdGames b -> ytdGamesC b
EGYtdMins b -> ytdMinsC b EGYtdMins b -> ytdMinsC b
EGYtdGoals b -> ytdGoalsC b EGYtdGoals b -> ytdGoalsC b
EGYtdWins b -> ytdWinsC b EGYtdShutouts b -> ytdShutoutsC b
EGYtdLosses b -> ytdLossesC b EGYtdWins b -> ytdWinsC b
EGYtdTies -> ytdTiesC EGYtdLosses b -> ytdLossesC b
EGLtGames b -> ltGamesC b EGYtdTies -> ytdTiesC
EGLtMins b -> ltMinsC b EGLtGames b -> ltGamesC b
EGLtGoals b -> ltGoalsC b EGLtMins b -> ltMinsC b
EGLtWins b -> ltWinsC b EGLtGoals b -> ltGoalsC b
EGLtLosses b -> ltLossesC b EGLtShutouts b -> ltShutoutsC b
EGLtTies -> ltTiesC EGLtWins b -> ltWinsC b
EGLtLosses b -> ltLossesC b
EGLtTies -> ltTiesC
menuC :: Controller menuC :: Controller
menuC = menuControllerWith header editGoalieMenu menuC = menuControllerWith header editGoalieMenu
@ -88,6 +90,9 @@ ytdMinsC = promptController . editGoalieYtdMinsPrompt
ytdGoalsC :: Bool -> Controller ytdGoalsC :: Bool -> Controller
ytdGoalsC = promptController . editGoalieYtdGoalsPrompt ytdGoalsC = promptController . editGoalieYtdGoalsPrompt
ytdShutoutsC :: Bool -> Controller
ytdShutoutsC = promptController . editGoalieYtdShutoutsPrompt
ytdWinsC :: Bool -> Controller ytdWinsC :: Bool -> Controller
ytdWinsC = promptController . editGoalieYtdWinsPrompt ytdWinsC = promptController . editGoalieYtdWinsPrompt
@ -106,6 +111,9 @@ ltMinsC = promptController . editGoalieLtMinsPrompt
ltGoalsC :: Bool -> Controller ltGoalsC :: Bool -> Controller
ltGoalsC = promptController . editGoalieLtGoalsPrompt ltGoalsC = promptController . editGoalieLtGoalsPrompt
ltShutoutsC :: Bool -> Controller
ltShutoutsC = promptController . editGoalieLtShutoutsPrompt
ltWinsC :: Bool -> Controller ltWinsC :: Bool -> Controller
ltWinsC = promptController . editGoalieLtWinsPrompt ltWinsC = promptController . editGoalieLtWinsPrompt

View File

@ -39,6 +39,7 @@ goalieDetails g = let
[ ( "Games played", gsGames ) [ ( "Games played", gsGames )
, ( "Mins played", gsMinsPlayed ) , ( "Mins played", gsMinsPlayed )
, ( "Goals allowed", gsGoalsAllowed ) , ( "Goals allowed", gsGoalsAllowed )
, ( "Shutouts", gsShutouts )
, ( "Wins", gsWins ) , ( "Wins", gsWins )
, ( "Losses", gsLosses ) , ( "Losses", gsLosses )
, ( "Ties", gsTies ) , ( "Ties", gsTies )

View File

@ -51,14 +51,15 @@ editGoalieMenu = Menu "*** EDIT GOALTENDER ***" () $ map
editGoalieYtdMenu :: Menu () editGoalieYtdMenu :: Menu ()
editGoalieYtdMenu = editMenu "*** EDIT GOALTENDER YEAR-TO-DATE ***" editGoalieYtdMenu = editMenu "*** EDIT GOALTENDER YEAR-TO-DATE ***"
-- key, label, value -- key, label, value
[ ( '1', "Edit all YTD stats", EGYtdGames True ) [ ( '1', "Edit all YTD stats", EGYtdGames True )
, ( '2', "Edit YTD games", EGYtdGames False ) , ( '2', "Edit YTD games", EGYtdGames False )
, ( '3', "Edit YTD minutes", EGYtdMins False ) , ( '3', "Edit YTD minutes", EGYtdMins False )
, ( '4', "Edit YTD goals", EGYtdGoals False ) , ( '4', "Edit YTD goals", EGYtdGoals False )
, ( '5', "Edit YTD wins", EGYtdWins False ) , ( '5', "Edit YTD shutouts", EGYtdShutouts False )
, ( '6', "Edit YTD losses", EGYtdLosses False ) , ( '6', "Edit YTD wins", EGYtdWins False )
, ( '7', "Edit YTD ties", EGYtdTies ) , ( '7', "Edit YTD losses", EGYtdLosses False )
, ( 'R', "Return to edit menu", EGMenu ) , ( '8', "Edit YTD ties", EGYtdTies )
, ( 'R', "Return to edit menu", EGMenu )
] ]
-- | The 'Goalie' lifetime edit menu -- | The 'Goalie' lifetime edit menu
@ -66,14 +67,15 @@ editGoalieLtMenu :: Menu ()
editGoalieLtMenu = editMenu editGoalieLtMenu = editMenu
"*** EDIT GOALTENDER LIFETIME ***" "*** EDIT GOALTENDER LIFETIME ***"
-- key, label, value -- key, label, value
[ ( '1', "Edit all lifetime stats", EGLtGames True ) [ ( '1', "Edit all lifetime stats", EGLtGames True )
, ( '2', "Edit lifetime games", EGLtGames False ) , ( '2', "Edit lifetime games", EGLtGames False )
, ( '3', "Edit lifetime minutes", EGLtMins False ) , ( '3', "Edit lifetime minutes", EGLtMins False )
, ( '4', "Edit lifetime goals", EGLtGoals False ) , ( '4', "Edit lifetime goals", EGLtGoals False )
, ( '5', "Edit lifetime wins", EGLtWins False ) , ( '5', "Edit lifetime shutouts", EGLtShutouts False )
, ( '6', "Edit lifetime losses", EGLtLosses False ) , ( '6', "Edit lifetime wins", EGLtWins False )
, ( '7', "Edit lifetime ties", EGLtTies ) , ( '7', "Edit lifetime losses", EGLtLosses False )
, ( 'R', "Return to edit menu", EGMenu ) , ( '8', "Edit lifetime ties", EGLtTies )
, ( 'R', "Return to edit menu", EGMenu )
] ]
editMenu :: String -> [(Char, String, EditGoalieMode)] -> Menu () editMenu :: String -> [(Char, String, EditGoalieMode)] -> Menu ()

View File

@ -26,12 +26,14 @@ module Mtlstats.Prompt.EditGoalie
, editGoalieYtdGamesPrompt , editGoalieYtdGamesPrompt
, editGoalieYtdMinsPrompt , editGoalieYtdMinsPrompt
, editGoalieYtdGoalsPrompt , editGoalieYtdGoalsPrompt
, editGoalieYtdShutoutsPrompt
, editGoalieYtdWinsPrompt , editGoalieYtdWinsPrompt
, editGoalieYtdLossesPrompt , editGoalieYtdLossesPrompt
, editGoalieYtdTiesPrompt , editGoalieYtdTiesPrompt
, editGoalieLtGamesPrompt , editGoalieLtGamesPrompt
, editGoalieLtMinsPrompt , editGoalieLtMinsPrompt
, editGoalieLtGoalsPrompt , editGoalieLtGoalsPrompt
, editGoalieLtShutoutsPrompt
, editGoalieLtWinsPrompt , editGoalieLtWinsPrompt
, editGoalieLtLossesPrompt , editGoalieLtLossesPrompt
, editGoalieLtTiesPrompt , editGoalieLtTiesPrompt
@ -92,6 +94,17 @@ editGoalieYtdGoalsPrompt
editGoalieYtdGoalsPrompt batchMode = editGoalieYtdGoalsPrompt batchMode =
editNum "Year-to-date goals allowed: " mode editNum "Year-to-date goals allowed: " mode
(gYtd.gsGoalsAllowed .~) (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 where
mode = if batchMode then EGYtdWins True else EGYtd mode = if batchMode then EGYtdWins True else EGYtd
@ -152,6 +165,17 @@ editGoalieLtGoalsPrompt
editGoalieLtGoalsPrompt batchMode = editGoalieLtGoalsPrompt batchMode =
editNum "Lifetime goals allowed: " mode editNum "Lifetime goals allowed: " mode
(gLifetime.gsGoalsAllowed .~) (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 where
mode = if batchMode then EGLtWins True else EGLifetime mode = if batchMode then EGLtWins True else EGLifetime

View File

@ -369,17 +369,19 @@ data EditGoalieMode
| EGName | EGName
| EGYtd | EGYtd
| EGLifetime | EGLifetime
| EGYtdGames Bool | EGYtdGames Bool
| EGYtdMins Bool | EGYtdMins Bool
| EGYtdGoals Bool | EGYtdGoals Bool
| EGYtdWins Bool | EGYtdShutouts Bool
| EGYtdLosses Bool | EGYtdWins Bool
| EGYtdLosses Bool
| EGYtdTies | EGYtdTies
| EGLtGames Bool | EGLtGames Bool
| EGLtMins Bool | EGLtMins Bool
| EGLtGoals Bool | EGLtGoals Bool
| EGLtWins Bool | EGLtShutouts Bool
| EGLtLosses Bool | EGLtWins Bool
| EGLtLosses Bool
| EGLtTies | EGLtTies
deriving (Eq, Show) deriving (Eq, Show)

View File

@ -38,28 +38,31 @@ goalieDetailsSpec = describe "goalieDetails" $ let
%~ ( gsGames .~ 2 ) %~ ( gsGames .~ 2 )
. ( gsMinsPlayed .~ 3 ) . ( gsMinsPlayed .~ 3 )
. ( gsGoalsAllowed .~ 4 ) . ( gsGoalsAllowed .~ 4 )
. ( gsWins .~ 5 ) . ( gsShutouts .~ 5 )
. ( gsLosses .~ 6 ) . ( gsWins .~ 6 )
. ( gsTies .~ 7 ) . ( gsLosses .~ 7 )
. ( gsTies .~ 8 )
& gLifetime & gLifetime
%~ ( gsGames .~ 8 ) %~ ( gsGames .~ 9 )
. ( gsMinsPlayed .~ 9 ) . ( gsMinsPlayed .~ 10 )
. ( gsGoalsAllowed .~ 10 ) . ( gsGoalsAllowed .~ 11 )
. ( gsWins .~ 11 ) . ( gsShutouts .~ 12 )
. ( gsLosses .~ 12 ) . ( gsWins .~ 13 )
. ( gsTies .~ 13 ) . ( gsLosses .~ 14 )
. ( gsTies .~ 15 )
expected = unlines expected = unlines
[ "Number: 1" [ "Number: 1"
, " Name: Joe" , " Name: Joe"
, "" , ""
, " YTD Lifetime" , " YTD Lifetime"
, " Games played 2 8" , " Games played 2 9"
, " Mins played 3 9" , " Mins played 3 10"
, "Goals allowed 4 10" , "Goals allowed 4 11"
, " Wins 5 11" , " Shutouts 5 12"
, " Losses 6 12" , " Wins 6 13"
, " Ties 7 13" , " Losses 7 14"
, " Ties 8 15"
] ]
in it "should format the output correctly" $ in it "should format the output correctly" $