allow batch editing of goalie YTD/lifetime stats

This commit is contained in:
Jonathan Lamothe 2020-01-02 00:07:29 -05:00
parent ac95601609
commit 071aa3bd8e
4 changed files with 143 additions and 81 deletions

View File

@ -51,17 +51,17 @@ editC = \case
EGName -> nameC EGName -> nameC
EGYtd -> ytdMenuC EGYtd -> ytdMenuC
EGLifetime -> lifetimeMenuC EGLifetime -> lifetimeMenuC
EGYtdGames -> ytdGamesC EGYtdGames b -> ytdGamesC b
EGYtdMins -> ytdMinsC EGYtdMins b -> ytdMinsC b
EGYtdGoals -> ytdGoalsC EGYtdGoals b -> ytdGoalsC b
EGYtdWins -> ytdWinsC EGYtdWins b -> ytdWinsC b
EGYtdLosses -> ytdLossesC EGYtdLosses b -> ytdLossesC b
EGYtdTies -> ytdTiesC EGYtdTies -> ytdTiesC
EGLtGames -> ltGamesC EGLtGames b -> ltGamesC b
EGLtMins -> ltMinsC EGLtMins b -> ltMinsC b
EGLtGoals -> ltGoalsC EGLtGoals b -> ltGoalsC b
EGLtWins -> ltWinsC EGLtWins b -> ltWinsC b
EGLtLosses -> ltLossesC EGLtLosses b -> ltLossesC b
EGLtTies -> ltTiesC EGLtTies -> ltTiesC
menuC :: Controller menuC :: Controller
@ -79,38 +79,38 @@ ytdMenuC = menuControllerWith header editGoalieYtdMenu
lifetimeMenuC :: Controller lifetimeMenuC :: Controller
lifetimeMenuC = menuControllerWith header editGoalieLtMenu lifetimeMenuC = menuControllerWith header editGoalieLtMenu
ytdGamesC :: Controller ytdGamesC :: Bool -> Controller
ytdGamesC = promptController editGoalieYtdGamesPrompt ytdGamesC = promptController . editGoalieYtdGamesPrompt
ytdMinsC :: Controller ytdMinsC :: Bool -> Controller
ytdMinsC = promptController editGoalieYtdMinsPrompt ytdMinsC = promptController . editGoalieYtdMinsPrompt
ytdGoalsC :: Controller ytdGoalsC :: Bool -> Controller
ytdGoalsC = promptController editGoalieYtdGoalsPrompt ytdGoalsC = promptController . editGoalieYtdGoalsPrompt
ytdWinsC :: Controller ytdWinsC :: Bool -> Controller
ytdWinsC = promptController editGoalieYtdWinsPrompt ytdWinsC = promptController . editGoalieYtdWinsPrompt
ytdLossesC :: Controller ytdLossesC :: Bool -> Controller
ytdLossesC = promptController editGoalieYtdLossesPrompt ytdLossesC = promptController . editGoalieYtdLossesPrompt
ytdTiesC :: Controller ytdTiesC :: Controller
ytdTiesC = promptController editGoalieYtdTiesPrompt ytdTiesC = promptController editGoalieYtdTiesPrompt
ltGamesC :: Controller ltGamesC :: Bool -> Controller
ltGamesC = promptController editGoalieLtGamesPrompt ltGamesC = promptController . editGoalieLtGamesPrompt
ltMinsC :: Controller ltMinsC :: Bool -> Controller
ltMinsC = promptController editGoalieLtMinsPrompt ltMinsC = promptController . editGoalieLtMinsPrompt
ltGoalsC :: Controller ltGoalsC :: Bool -> Controller
ltGoalsC = promptController editGoalieLtGoalsPrompt ltGoalsC = promptController . editGoalieLtGoalsPrompt
ltWinsC :: Controller ltWinsC :: Bool -> Controller
ltWinsC = promptController editGoalieLtWinsPrompt ltWinsC = promptController . editGoalieLtWinsPrompt
ltLossesC :: Controller ltLossesC :: Bool -> Controller
ltLossesC = promptController editGoalieLtLossesPrompt ltLossesC = promptController . editGoalieLtLossesPrompt
ltTiesC :: Controller ltTiesC :: Controller
ltTiesC = promptController editGoalieLtTiesPrompt ltTiesC = promptController editGoalieLtTiesPrompt

View File

@ -51,12 +51,13 @@ 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 YTD games", EGYtdGames ) [ ( '1', "Edit all YTD stats", EGYtdGames True )
, ( '2', "Edit YTD minutes", EGYtdMins ) , ( '2', "Edit YTD games", EGYtdGames False )
, ( '3', "Edit YTD goals", EGYtdGoals ) , ( '3', "Edit YTD minutes", EGYtdMins False )
, ( '4', "Edit YTD wins", EGYtdWins ) , ( '4', "Edit YTD goals", EGYtdGoals False )
, ( '5', "Edit YTD losses", EGYtdLosses ) , ( '5', "Edit YTD wins", EGYtdWins False )
, ( '6', "Edit YTD ties", EGYtdTies ) , ( '6', "Edit YTD losses", EGYtdLosses False )
, ( '7', "Edit YTD ties", EGYtdTies )
, ( 'R', "Return to edit menu", EGMenu ) , ( 'R', "Return to edit menu", EGMenu )
] ]
@ -65,12 +66,13 @@ editGoalieLtMenu :: Menu ()
editGoalieLtMenu = editMenu editGoalieLtMenu = editMenu
"*** EDIT GOALTENDER LIFETIME ***" "*** EDIT GOALTENDER LIFETIME ***"
-- key, label, value -- key, label, value
[ ( '1', "Edit lifetime games", EGLtGames ) [ ( '1', "Edit all lifetime stats", EGLtGames True )
, ( '2', "Edit lifetime minutes", EGLtMins ) , ( '2', "Edit lifetime games", EGLtGames False )
, ( '3', "Edit lifetime goals", EGLtGoals ) , ( '3', "Edit lifetime minutes", EGLtMins False )
, ( '4', "Edit lifetime wins", EGLtWins ) , ( '4', "Edit lifetime goals", EGLtGoals False )
, ( '5', "Edit lifetime losses", EGLtLosses ) , ( '5', "Edit lifetime wins", EGLtWins False )
, ( '6', "Edit lifetime ties", EGLtTies ) , ( '6', "Edit lifetime losses", EGLtLosses False )
, ( '7', "Edit lifetime ties", EGLtTies )
, ( 'R', "Return to edit menu", EGMenu ) , ( 'R', "Return to edit menu", EGMenu )
] ]

View File

@ -63,29 +63,59 @@ editGoalieNamePrompt = namePrompt "Goalie name: " $ \name ->
else editGoalie EGMenu $ gName .~ name else editGoalie EGMenu $ gName .~ name
-- | Prompt to edit a goalie's YTD games played -- | Prompt to edit a goalie's YTD games played
editGoalieYtdGamesPrompt :: Prompt editGoalieYtdGamesPrompt
editGoalieYtdGamesPrompt = editNum "Year-to-date games played: " EGYtd :: Bool
-- ^ Indicates whether or not we're in batch mode
-> Prompt
editGoalieYtdGamesPrompt batchMode =
editNum "Year-to-date games played: " mode
(gYtd.gsGames .~) (gYtd.gsGames .~)
where
mode = if batchMode then EGYtdMins True else EGYtd
-- | Prompt to edit a goalie's YTD minutes played -- | Prompt to edit a goalie's YTD minutes played
editGoalieYtdMinsPrompt :: Prompt editGoalieYtdMinsPrompt
editGoalieYtdMinsPrompt = editNum "Year-to-date minutes played: " EGYtd :: Bool
-- ^ Indicates whether or not we're in batch mode
-> Prompt
editGoalieYtdMinsPrompt batchMode =
editNum "Year-to-date minutes played: " mode
(gYtd.gsMinsPlayed .~) (gYtd.gsMinsPlayed .~)
where
mode = if batchMode then EGYtdGoals True else EGYtd
-- | Prompt to edit a goalie's YTD goales allowed -- | Prompt to edit a goalie's YTD goales allowed
editGoalieYtdGoalsPrompt :: Prompt editGoalieYtdGoalsPrompt
editGoalieYtdGoalsPrompt = editNum "Year-to-date goals allowed: " EGYtd :: Bool
-- ^ Indicates whether or not we're in batch mode
-> Prompt
editGoalieYtdGoalsPrompt batchMode =
editNum "Year-to-date goals allowed: " mode
(gYtd.gsGoalsAllowed .~) (gYtd.gsGoalsAllowed .~)
where
mode = if batchMode then EGYtdWins True else EGYtd
-- | Prompt to edit a goalie's YTD wins -- | Prompt to edit a goalie's YTD wins
editGoalieYtdWinsPrompt :: Prompt editGoalieYtdWinsPrompt
editGoalieYtdWinsPrompt = editNum "Year-to-date wins: " EGYtd :: Bool
-- ^ Indicates whether or not we're in batch mode
-> Prompt
editGoalieYtdWinsPrompt batchMode =
editNum "Year-to-date wins: " mode
(gYtd.gsWins .~) (gYtd.gsWins .~)
where
mode = if batchMode then EGYtdLosses True else EGYtd
-- | Prompt to edit a goalie's YTD losses -- | Prompt to edit a goalie's YTD losses
editGoalieYtdLossesPrompt :: Prompt editGoalieYtdLossesPrompt
editGoalieYtdLossesPrompt = editNum "Year-to-date losses: " EGYtd :: Bool
-- ^ Indicates whether or not we're in batch mode
-> Prompt
editGoalieYtdLossesPrompt batchMode =
editNum "Year-to-date losses: " mode
(gYtd.gsLosses .~) (gYtd.gsLosses .~)
where
mode = if batchMode then EGYtdTies else EGYtd
-- | Prompt to edit a goalie's YTD ties -- | Prompt to edit a goalie's YTD ties
editGoalieYtdTiesPrompt :: Prompt editGoalieYtdTiesPrompt :: Prompt
@ -93,29 +123,59 @@ editGoalieYtdTiesPrompt = editNum "Year-to-date ties: " EGYtd
(gYtd.gsTies .~) (gYtd.gsTies .~)
-- | Prompt to edit a goalie's lifetime games played -- | Prompt to edit a goalie's lifetime games played
editGoalieLtGamesPrompt :: Prompt editGoalieLtGamesPrompt
editGoalieLtGamesPrompt = editNum "Lifetime games played: " EGLifetime :: Bool
-- ^ Indicates whether or not we're in batch mode
-> Prompt
editGoalieLtGamesPrompt batchMode =
editNum "Lifetime games played: " mode
(gLifetime.gsGames .~) (gLifetime.gsGames .~)
where
mode = if batchMode then EGLtMins True else EGLifetime
-- | Prompt to edit a goalie's lifetime minutes played -- | Prompt to edit a goalie's lifetime minutes played
editGoalieLtMinsPrompt :: Prompt editGoalieLtMinsPrompt
editGoalieLtMinsPrompt = editNum "Lifetime minutes played: " EGLifetime :: Bool
-- ^ Indicates whether or not we're in batch mode
-> Prompt
editGoalieLtMinsPrompt batchMode =
editNum "Lifetime minutes played: " mode
(gLifetime.gsMinsPlayed .~) (gLifetime.gsMinsPlayed .~)
where
mode = if batchMode then EGLtGoals True else EGLifetime
-- | Prompt to edit a goalie's lifetime goals allowed -- | Prompt to edit a goalie's lifetime goals allowed
editGoalieLtGoalsPrompt :: Prompt editGoalieLtGoalsPrompt
editGoalieLtGoalsPrompt = editNum "Lifetime goals allowed: " EGLifetime :: Bool
-- ^ Indicates whether or not we're in batch mode
-> Prompt
editGoalieLtGoalsPrompt batchMode =
editNum "Lifetime goals allowed: " mode
(gLifetime.gsGoalsAllowed .~) (gLifetime.gsGoalsAllowed .~)
where
mode = if batchMode then EGLtWins True else EGLifetime
-- | Prompt to edit a goalie's lifetime wins -- | Prompt to edit a goalie's lifetime wins
editGoalieLtWinsPrompt :: Prompt editGoalieLtWinsPrompt
editGoalieLtWinsPrompt = editNum "Lifetime wins: " EGLifetime :: Bool
-- ^ Indicates whether or not we're in batch mode
-> Prompt
editGoalieLtWinsPrompt batchMode =
editNum "Lifetime wins: " mode
(gLifetime.gsWins .~) (gLifetime.gsWins .~)
where
mode = if batchMode then EGLtLosses True else EGLifetime
-- | Prompt to edit a goalie's lifetime losses -- | Prompt to edit a goalie's lifetime losses
editGoalieLtLossesPrompt :: Prompt editGoalieLtLossesPrompt
editGoalieLtLossesPrompt = editNum "Lifetime losses: " EGLifetime :: Bool
-- ^ Indicates whether or not we're in batch mode
-> Prompt
editGoalieLtLossesPrompt batchMode =
editNum "Lifetime losses: " mode
(gLifetime.gsLosses .~) (gLifetime.gsLosses .~)
where
mode = if batchMode then EGLtTies else EGLifetime
-- | Prompt to edit a goalie's lifetime ties -- | Prompt to edit a goalie's lifetime ties
editGoalieLtTiesPrompt :: Prompt editGoalieLtTiesPrompt :: Prompt

View File

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