implemented batch editing of all player ytd/lifetime stats

This commit is contained in:
Jonathan Lamothe 2020-01-01 22:57:16 -05:00
parent 34b743a55b
commit 30807b7e2e
4 changed files with 62 additions and 40 deletions

View File

@ -38,18 +38,18 @@ editPlayerC :: EditPlayerState -> Controller
editPlayerC eps editPlayerC eps
| null $ eps^.epsSelectedPlayer = selectPlayerC | null $ eps^.epsSelectedPlayer = selectPlayerC
| otherwise = case eps^.epsMode of | otherwise = case eps^.epsMode of
EPMenu -> menuC EPMenu -> menuC
EPNumber -> numberC EPNumber -> numberC
EPName -> nameC EPName -> nameC
EPPosition -> positionC EPPosition -> positionC
EPYtd -> ytdC EPYtd -> ytdC
EPLifetime -> lifetimeC EPLifetime -> lifetimeC
EPYtdGoals -> ytdGoalsC EPYtdGoals b -> ytdGoalsC b
EPYtdAssists -> ytdAssistsC EPYtdAssists b -> ytdAssistsC b
EPYtdPMin -> ytdPMinC EPYtdPMin -> ytdPMinC
EPLtGoals -> ltGoalsC EPLtGoals b -> ltGoalsC b
EPLtAssists -> ltAssistsC EPLtAssists b -> ltAssistsC b
EPLtPMin -> ltPMinC EPLtPMin -> ltPMinC
selectPlayerC :: Controller selectPlayerC :: Controller
selectPlayerC = promptController playerToEditPrompt selectPlayerC = promptController playerToEditPrompt
@ -72,20 +72,20 @@ ytdC = menuControllerWith header editPlayerYtdMenu
lifetimeC :: Controller lifetimeC :: Controller
lifetimeC = menuControllerWith header editPlayerLtMenu lifetimeC = menuControllerWith header editPlayerLtMenu
ytdGoalsC :: Controller ytdGoalsC :: Bool -> Controller
ytdGoalsC = promptController editPlayerYtdGoalsPrompt ytdGoalsC = promptController . editPlayerYtdGoalsPrompt
ytdAssistsC :: Controller ytdAssistsC :: Bool -> Controller
ytdAssistsC = promptController editPlayerYtdAssistsPrompt ytdAssistsC = promptController . editPlayerYtdAssistsPrompt
ytdPMinC :: Controller ytdPMinC :: Controller
ytdPMinC = promptController editPlayerYtdPMinPrompt ytdPMinC = promptController editPlayerYtdPMinPrompt
ltGoalsC :: Controller ltGoalsC :: Bool -> Controller
ltGoalsC = promptController editPlayerLtGoalsPrompt ltGoalsC = promptController . editPlayerLtGoalsPrompt
ltAssistsC :: Controller ltAssistsC :: Bool -> Controller
ltAssistsC = promptController editPlayerLtAssistsPrompt ltAssistsC = promptController . editPlayerLtAssistsPrompt
ltPMinC :: Controller ltPMinC :: Controller
ltPMinC = promptController editPlayerLtPMinPrompt ltPMinC = promptController editPlayerLtPMinPrompt

View File

@ -53,10 +53,11 @@ editPlayerYtdMenu :: Menu ()
editPlayerYtdMenu = editMenu editPlayerYtdMenu = editMenu
"*** EDIT PLAYER YEAR-TO-DATE ***" "*** EDIT PLAYER YEAR-TO-DATE ***"
-- key, label, value -- key, label, value
[ ( '1', "Edit YTD goals", EPYtdGoals ) [ ( '1', "Edit all YTD stats", EPYtdGoals True )
, ( '2', "Edit YTD assists", EPYtdAssists ) , ( '2', "Edit YTD goals", EPYtdGoals False )
, ( '3', "Edit YTD penalty mins", EPYtdPMin ) , ( '3', "Edit YTD assists", EPYtdAssists False )
, ( 'R', "Return to player edit menu", EPMenu ) , ( '4', "Edit YTD penalty mins", EPYtdPMin )
, ( 'R', "Return to player edit menu", EPMenu )
] ]
-- | The 'Player' lifetime stats edit menu -- | The 'Player' lifetime stats edit menu
@ -64,10 +65,11 @@ editPlayerLtMenu :: Menu ()
editPlayerLtMenu = editMenu editPlayerLtMenu = editMenu
"*** EDIT PLAYER LIFETIME ***" "*** EDIT PLAYER LIFETIME ***"
-- key, label, value -- key, label, value
[ ( '1', "Edit lifetime goals", EPLtGoals ) [ ( '1', "Edit all lifetime stats", EPLtGoals True )
, ( '2', "Edit lifetime assits", EPLtAssists ) , ( '2', "Edit lifetime goals", EPLtGoals False )
, ( '3', "Edit lifetime penalty mins", EPLtPMin ) , ( '3', "Edit lifetime assits", EPLtAssists False )
, ( 'R', "Return to edit player menu", EPMenu ) , ( '4', "Edit lifetime penalty mins", EPLtPMin )
, ( 'R', "Return to edit player menu", EPMenu )
] ]
editMenu :: String -> [(Char, String, EditPlayerMode)] -> Menu () editMenu :: String -> [(Char, String, EditPlayerMode)] -> Menu ()

View File

@ -59,14 +59,24 @@ editPlayerPosPrompt = ucStrPrompt "Player position: " $ \pos ->
else editPlayer EPMenu $ pPosition .~ pos else editPlayer EPMenu $ pPosition .~ pos
-- | Prompt to edit a player's year-to-date goals -- | Prompt to edit a player's year-to-date goals
editPlayerYtdGoalsPrompt :: Prompt editPlayerYtdGoalsPrompt
editPlayerYtdGoalsPrompt = editNum "Year-to-date goals: " EPYtd :: Bool
-- ^ Indicates wheter or not we're editing in batch mode
-> Prompt
editPlayerYtdGoalsPrompt batchMode = editNum "Year-to-date goals: " mode
(pYtd.psGoals .~) (pYtd.psGoals .~)
where
mode = if batchMode then EPYtdAssists True else EPYtd
-- | Prompt to edit a player's year-to-date assists -- | Prompt to edit a player's year-to-date assists
editPlayerYtdAssistsPrompt :: Prompt editPlayerYtdAssistsPrompt
editPlayerYtdAssistsPrompt = editNum "Year-to-date assists: " EPYtd :: Bool
-- ^ Indicates wheter or not we're editing in batch mode
-> Prompt
editPlayerYtdAssistsPrompt batchMode = editNum "Year-to-date assists: " mode
(pYtd.psAssists .~) (pYtd.psAssists .~)
where
mode = if batchMode then EPYtdPMin else EPYtd
-- | Prompt to edit a player's year-to-date penalty minutes -- | Prompt to edit a player's year-to-date penalty minutes
editPlayerYtdPMinPrompt :: Prompt editPlayerYtdPMinPrompt :: Prompt
@ -74,14 +84,24 @@ editPlayerYtdPMinPrompt = editNum "Year-to-date penalty minutes: " EPYtd
(pYtd.psPMin .~) (pYtd.psPMin .~)
-- | Prompt to edit a player's lifetime goals -- | Prompt to edit a player's lifetime goals
editPlayerLtGoalsPrompt :: Prompt editPlayerLtGoalsPrompt
editPlayerLtGoalsPrompt = editNum "Lifetime goals: " EPLifetime :: Bool
-- ^ Indicates wheter or not we're editing in batch mode
-> Prompt
editPlayerLtGoalsPrompt batchMode = editNum "Lifetime goals: " mode
(pLifetime.psGoals .~) (pLifetime.psGoals .~)
where
mode = if batchMode then EPLtAssists True else EPLifetime
-- | Prompt to edit a player's lifetime assists -- | Prompt to edit a player's lifetime assists
editPlayerLtAssistsPrompt :: Prompt editPlayerLtAssistsPrompt
editPlayerLtAssistsPrompt = editNum "Lifetime assists: " EPLifetime :: Bool
-- ^ Indicates wheter or not we're editing in batch mode
-> Prompt
editPlayerLtAssistsPrompt batchMode = editNum "Lifetime assists: " mode
(pLifetime.psAssists .~) (pLifetime.psAssists .~)
where
mode = if batchMode then EPLtPMin else EPLifetime
-- | Prompt to edit a player's lifetime penalty minutes -- | Prompt to edit a player's lifetime penalty minutes
editPlayerLtPMinPrompt :: Prompt editPlayerLtPMinPrompt :: Prompt

View File

@ -347,11 +347,11 @@ data EditPlayerMode
| EPPosition | EPPosition
| EPYtd | EPYtd
| EPLifetime | EPLifetime
| EPYtdGoals | EPYtdGoals Bool
| EPYtdAssists | EPYtdAssists Bool
| EPYtdPMin | EPYtdPMin
| EPLtGoals | EPLtGoals Bool
| EPLtAssists | EPLtAssists Bool
| EPLtPMin | EPLtPMin
deriving (Eq, Show) deriving (Eq, Show)