2019-11-09 02:05:51 -05:00
|
|
|
{- |
|
|
|
|
|
|
|
|
mtlstats
|
2020-01-11 00:29:45 -05:00
|
|
|
Copyright (C) 1984, 1985, 2019, 2020 Rhéal Lamothe
|
2019-11-09 02:05:51 -05:00
|
|
|
<rheal.lamothe@gmail.com>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or (at
|
|
|
|
your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
2019-11-12 23:51:49 -05:00
|
|
|
module Mtlstats.Prompt.EditGoalie
|
|
|
|
( goalieToEditPrompt
|
|
|
|
, editGoalieNumberPrompt
|
2019-11-13 11:34:25 -05:00
|
|
|
, editGoalieNamePrompt
|
2019-11-14 00:44:38 -05:00
|
|
|
, editGoalieYtdGamesPrompt
|
2019-11-14 01:01:30 -05:00
|
|
|
, editGoalieYtdMinsPrompt
|
2019-11-14 01:17:19 -05:00
|
|
|
, editGoalieYtdGoalsPrompt
|
2020-01-02 00:42:04 -05:00
|
|
|
, editGoalieYtdShutoutsPrompt
|
2019-11-14 01:37:58 -05:00
|
|
|
, editGoalieYtdWinsPrompt
|
2019-11-14 01:49:22 -05:00
|
|
|
, editGoalieYtdLossesPrompt
|
2019-11-14 02:00:10 -05:00
|
|
|
, editGoalieYtdTiesPrompt
|
2019-11-14 02:09:20 -05:00
|
|
|
, editGoalieLtGamesPrompt
|
2019-11-14 02:19:28 -05:00
|
|
|
, editGoalieLtMinsPrompt
|
2019-11-14 02:28:53 -05:00
|
|
|
, editGoalieLtGoalsPrompt
|
2020-01-02 00:42:04 -05:00
|
|
|
, editGoalieLtShutoutsPrompt
|
2019-11-14 02:38:08 -05:00
|
|
|
, editGoalieLtWinsPrompt
|
2019-11-14 02:47:57 -05:00
|
|
|
, editGoalieLtLossesPrompt
|
2019-11-14 02:55:50 -05:00
|
|
|
, editGoalieLtTiesPrompt
|
2019-11-12 23:51:49 -05:00
|
|
|
) where
|
2019-11-09 02:05:51 -05:00
|
|
|
|
2020-01-09 01:35:37 -05:00
|
|
|
import Control.Monad.Trans.State (modify)
|
|
|
|
import Lens.Micro ((.~))
|
2019-11-11 15:30:04 -05:00
|
|
|
|
2020-01-09 01:35:37 -05:00
|
|
|
import Mtlstats.Actions
|
2019-11-11 15:30:04 -05:00
|
|
|
import Mtlstats.Prompt
|
2019-11-09 02:05:51 -05:00
|
|
|
import Mtlstats.Types
|
|
|
|
|
|
|
|
-- | Prompt to select a 'Goalie' for editing
|
|
|
|
goalieToEditPrompt :: Prompt
|
2019-11-11 15:30:04 -05:00
|
|
|
goalieToEditPrompt = selectGoaliePrompt "Goalie to edit: " $
|
|
|
|
modify . (progMode.editGoalieStateL.egsSelectedGoalie .~)
|
2019-11-12 23:51:49 -05:00
|
|
|
|
|
|
|
-- | Prompt to edit a goalie's number
|
2020-01-31 21:14:56 -05:00
|
|
|
editGoalieNumberPrompt
|
|
|
|
:: Action ()
|
|
|
|
-- ^ Action to perform on completion
|
|
|
|
-> Prompt
|
2020-01-01 23:36:37 -05:00
|
|
|
editGoalieNumberPrompt = editNum "Goalie number: " EGMenu
|
|
|
|
(gNumber .~)
|
2019-11-13 11:34:25 -05:00
|
|
|
|
|
|
|
-- | Prompt to edit a goalie's name
|
2020-01-31 21:14:56 -05:00
|
|
|
editGoalieNamePrompt
|
|
|
|
:: Action ()
|
|
|
|
-- ^ Action to perform on completion
|
|
|
|
-> Prompt
|
|
|
|
editGoalieNamePrompt cb = namePrompt "Goalie name: " $ \name -> do
|
2020-01-01 23:36:37 -05:00
|
|
|
if null name
|
2020-01-31 21:14:56 -05:00
|
|
|
then goto EGMenu
|
|
|
|
else doEdit EGMenu $ gName .~ name
|
|
|
|
cb
|
2019-11-14 00:44:38 -05:00
|
|
|
|
|
|
|
-- | Prompt to edit a goalie's YTD games played
|
2020-01-02 00:07:29 -05:00
|
|
|
editGoalieYtdGamesPrompt
|
|
|
|
:: Bool
|
|
|
|
-- ^ Indicates whether or not we're in batch mode
|
2020-01-31 21:14:56 -05:00
|
|
|
-> Action ()
|
|
|
|
-- ^ Action to perform on completion
|
2020-01-02 00:07:29 -05:00
|
|
|
-> Prompt
|
2020-01-31 21:14:56 -05:00
|
|
|
editGoalieYtdGamesPrompt batchMode cb =
|
2020-01-02 00:07:29 -05:00
|
|
|
editNum "Year-to-date games played: " mode
|
2020-01-31 21:14:56 -05:00
|
|
|
(gYtd.gsGames .~) cb'
|
2020-01-02 00:07:29 -05:00
|
|
|
where
|
2020-01-31 21:14:56 -05:00
|
|
|
(mode, cb') = if batchMode
|
|
|
|
then (EGYtdMins True, return ())
|
|
|
|
else (EGYtd, cb)
|
2019-11-14 01:01:30 -05:00
|
|
|
|
|
|
|
-- | Prompt to edit a goalie's YTD minutes played
|
2020-01-02 00:07:29 -05:00
|
|
|
editGoalieYtdMinsPrompt
|
|
|
|
:: Bool
|
|
|
|
-- ^ Indicates whether or not we're in batch mode
|
2020-01-31 21:14:56 -05:00
|
|
|
-> Action ()
|
|
|
|
-- ^ Action to perform on completion
|
2020-01-02 00:07:29 -05:00
|
|
|
-> Prompt
|
2020-01-31 21:14:56 -05:00
|
|
|
editGoalieYtdMinsPrompt batchMode cb =
|
2020-01-02 00:07:29 -05:00
|
|
|
editNum "Year-to-date minutes played: " mode
|
2020-01-31 21:14:56 -05:00
|
|
|
(gYtd.gsMinsPlayed .~) cb'
|
2020-01-02 00:07:29 -05:00
|
|
|
where
|
2020-01-31 21:14:56 -05:00
|
|
|
(mode, cb') = if batchMode
|
|
|
|
then (EGYtdGoals True, return ())
|
|
|
|
else (EGYtd, cb)
|
2019-11-14 01:17:19 -05:00
|
|
|
|
|
|
|
-- | Prompt to edit a goalie's YTD goales allowed
|
2020-01-02 00:07:29 -05:00
|
|
|
editGoalieYtdGoalsPrompt
|
|
|
|
:: Bool
|
|
|
|
-- ^ Indicates whether or not we're in batch mode
|
2020-01-31 21:14:56 -05:00
|
|
|
-> Action ()
|
|
|
|
-- ^ Action to perform on completion
|
2020-01-02 00:07:29 -05:00
|
|
|
-> Prompt
|
2020-01-31 21:14:56 -05:00
|
|
|
editGoalieYtdGoalsPrompt batchMode cb =
|
2020-01-02 00:07:29 -05:00
|
|
|
editNum "Year-to-date goals allowed: " mode
|
2020-01-31 21:14:56 -05:00
|
|
|
(gYtd.gsGoalsAllowed .~) cb'
|
2020-01-02 00:42:04 -05:00
|
|
|
where
|
2020-01-31 21:14:56 -05:00
|
|
|
(mode, cb') = if batchMode
|
|
|
|
then (EGYtdShutouts True, return ())
|
|
|
|
else (EGYtd, cb)
|
2020-01-02 00:42:04 -05:00
|
|
|
|
|
|
|
-- | Prompt to edit a goalie's YTD shutouts
|
|
|
|
editGoalieYtdShutoutsPrompt
|
|
|
|
:: Bool
|
|
|
|
-- ^ Indicates whether or not we're in batch mode
|
2020-01-31 21:14:56 -05:00
|
|
|
-> Action ()
|
|
|
|
-- ^ Action to perform on completion
|
2020-01-02 00:42:04 -05:00
|
|
|
-> Prompt
|
2020-01-31 21:14:56 -05:00
|
|
|
editGoalieYtdShutoutsPrompt batchMode cb =
|
2020-01-02 00:42:04 -05:00
|
|
|
editNum "Year-to-date shutouts: " mode
|
2020-01-31 21:14:56 -05:00
|
|
|
(gYtd.gsShutouts .~) cb'
|
2020-01-02 00:07:29 -05:00
|
|
|
where
|
2020-01-31 21:14:56 -05:00
|
|
|
(mode, cb') = if batchMode
|
|
|
|
then (EGYtdWins True, return ())
|
|
|
|
else (EGYtd, cb)
|
2019-11-14 01:37:58 -05:00
|
|
|
|
|
|
|
-- | Prompt to edit a goalie's YTD wins
|
2020-01-02 00:07:29 -05:00
|
|
|
editGoalieYtdWinsPrompt
|
|
|
|
:: Bool
|
|
|
|
-- ^ Indicates whether or not we're in batch mode
|
2020-01-31 21:14:56 -05:00
|
|
|
-> Action ()
|
|
|
|
-- ^ Action to perform on completion
|
2020-01-02 00:07:29 -05:00
|
|
|
-> Prompt
|
2020-01-31 21:14:56 -05:00
|
|
|
editGoalieYtdWinsPrompt batchMode cb =
|
2020-01-02 00:07:29 -05:00
|
|
|
editNum "Year-to-date wins: " mode
|
2020-01-31 21:14:56 -05:00
|
|
|
(gYtd.gsWins .~) cb'
|
2020-01-02 00:07:29 -05:00
|
|
|
where
|
2020-01-31 21:14:56 -05:00
|
|
|
(mode, cb') = if batchMode
|
|
|
|
then (EGYtdLosses True, return ())
|
|
|
|
else (EGYtd, cb)
|
2019-11-14 01:49:22 -05:00
|
|
|
|
|
|
|
-- | Prompt to edit a goalie's YTD losses
|
2020-01-02 00:07:29 -05:00
|
|
|
editGoalieYtdLossesPrompt
|
|
|
|
:: Bool
|
|
|
|
-- ^ Indicates whether or not we're in batch mode
|
2020-01-31 21:14:56 -05:00
|
|
|
-> Action ()
|
|
|
|
-- ^ Action to perform on completion
|
2020-01-02 00:07:29 -05:00
|
|
|
-> Prompt
|
2020-01-31 21:14:56 -05:00
|
|
|
editGoalieYtdLossesPrompt batchMode cb =
|
2020-01-02 00:07:29 -05:00
|
|
|
editNum "Year-to-date losses: " mode
|
2020-01-31 21:14:56 -05:00
|
|
|
(gYtd.gsLosses .~) cb'
|
2020-01-02 00:07:29 -05:00
|
|
|
where
|
2020-01-31 21:14:56 -05:00
|
|
|
(mode, cb') = if batchMode
|
|
|
|
then (EGYtdTies, return ())
|
|
|
|
else (EGYtd, cb)
|
2019-11-14 02:00:10 -05:00
|
|
|
|
|
|
|
-- | Prompt to edit a goalie's YTD ties
|
2020-01-31 21:14:56 -05:00
|
|
|
editGoalieYtdTiesPrompt
|
|
|
|
:: Action ()
|
|
|
|
-- ^ Action to perform on completion
|
|
|
|
-> Prompt
|
2020-01-01 23:36:37 -05:00
|
|
|
editGoalieYtdTiesPrompt = editNum "Year-to-date ties: " EGYtd
|
|
|
|
(gYtd.gsTies .~)
|
2019-11-14 02:09:20 -05:00
|
|
|
|
|
|
|
-- | Prompt to edit a goalie's lifetime games played
|
2020-01-02 00:07:29 -05:00
|
|
|
editGoalieLtGamesPrompt
|
|
|
|
:: Bool
|
|
|
|
-- ^ Indicates whether or not we're in batch mode
|
2020-01-31 21:14:56 -05:00
|
|
|
-> Action ()
|
|
|
|
-- ^ Action to perform on completion
|
2020-01-02 00:07:29 -05:00
|
|
|
-> Prompt
|
2020-01-31 21:14:56 -05:00
|
|
|
editGoalieLtGamesPrompt batchMode cb =
|
2020-01-02 00:07:29 -05:00
|
|
|
editNum "Lifetime games played: " mode
|
2020-01-31 21:14:56 -05:00
|
|
|
(gLifetime.gsGames .~) cb'
|
2020-01-02 00:07:29 -05:00
|
|
|
where
|
2020-01-31 21:14:56 -05:00
|
|
|
(mode, cb') = if batchMode
|
|
|
|
then (EGLtMins True, return ())
|
|
|
|
else (EGLifetime, cb)
|
2019-11-14 02:19:28 -05:00
|
|
|
|
|
|
|
-- | Prompt to edit a goalie's lifetime minutes played
|
2020-01-02 00:07:29 -05:00
|
|
|
editGoalieLtMinsPrompt
|
|
|
|
:: Bool
|
|
|
|
-- ^ Indicates whether or not we're in batch mode
|
2020-01-31 21:14:56 -05:00
|
|
|
-> Action ()
|
|
|
|
-- ^ Action to perform on completion
|
2020-01-02 00:07:29 -05:00
|
|
|
-> Prompt
|
2020-01-31 21:14:56 -05:00
|
|
|
editGoalieLtMinsPrompt batchMode cb =
|
2020-01-02 00:07:29 -05:00
|
|
|
editNum "Lifetime minutes played: " mode
|
2020-01-31 21:14:56 -05:00
|
|
|
(gLifetime.gsMinsPlayed .~) cb'
|
2020-01-02 00:07:29 -05:00
|
|
|
where
|
2020-01-31 21:14:56 -05:00
|
|
|
(mode, cb') = if batchMode
|
|
|
|
then (EGLtGoals True, return ())
|
|
|
|
else (EGLifetime, cb)
|
2019-11-14 02:28:53 -05:00
|
|
|
|
|
|
|
-- | Prompt to edit a goalie's lifetime goals allowed
|
2020-01-02 00:07:29 -05:00
|
|
|
editGoalieLtGoalsPrompt
|
|
|
|
:: Bool
|
|
|
|
-- ^ Indicates whether or not we're in batch mode
|
2020-01-31 21:14:56 -05:00
|
|
|
-> Action ()
|
|
|
|
-- ^ Action to perform on completion
|
2020-01-02 00:07:29 -05:00
|
|
|
-> Prompt
|
2020-01-31 21:14:56 -05:00
|
|
|
editGoalieLtGoalsPrompt batchMode cb =
|
2020-01-02 00:07:29 -05:00
|
|
|
editNum "Lifetime goals allowed: " mode
|
2020-01-31 21:14:56 -05:00
|
|
|
(gLifetime.gsGoalsAllowed .~) cb'
|
2020-01-02 00:42:04 -05:00
|
|
|
where
|
2020-01-31 21:14:56 -05:00
|
|
|
(mode, cb') = if batchMode
|
|
|
|
then (EGLtShutouts True, return ())
|
|
|
|
else (EGLifetime, cb)
|
2020-01-02 00:42:04 -05:00
|
|
|
|
|
|
|
-- | Prompt to edit a goalie's lifetime shutouts
|
|
|
|
editGoalieLtShutoutsPrompt
|
|
|
|
:: Bool
|
|
|
|
-- ^ Indicates whether or not we're in batch mode
|
2020-01-31 21:14:56 -05:00
|
|
|
-> Action ()
|
|
|
|
-- ^ Action to perform on completion
|
2020-01-02 00:42:04 -05:00
|
|
|
-> Prompt
|
2020-01-31 21:14:56 -05:00
|
|
|
editGoalieLtShutoutsPrompt batchMode cb =
|
2020-01-02 00:42:04 -05:00
|
|
|
editNum "Lifetime shutouts: " mode
|
2020-01-31 21:14:56 -05:00
|
|
|
(gLifetime.gsShutouts .~) cb'
|
2020-01-02 00:07:29 -05:00
|
|
|
where
|
2020-01-31 21:14:56 -05:00
|
|
|
(mode, cb') = if batchMode
|
|
|
|
then (EGLtWins True, return ())
|
|
|
|
else (EGLifetime, cb)
|
2019-11-14 02:38:08 -05:00
|
|
|
|
|
|
|
-- | Prompt to edit a goalie's lifetime wins
|
2020-01-02 00:07:29 -05:00
|
|
|
editGoalieLtWinsPrompt
|
|
|
|
:: Bool
|
|
|
|
-- ^ Indicates whether or not we're in batch mode
|
2020-01-31 21:14:56 -05:00
|
|
|
-> Action ()
|
|
|
|
-- ^ Action to perform on completion
|
2020-01-02 00:07:29 -05:00
|
|
|
-> Prompt
|
2020-01-31 21:14:56 -05:00
|
|
|
editGoalieLtWinsPrompt batchMode cb =
|
2020-01-02 00:07:29 -05:00
|
|
|
editNum "Lifetime wins: " mode
|
2020-01-31 21:14:56 -05:00
|
|
|
(gLifetime.gsWins .~) cb'
|
2020-01-02 00:07:29 -05:00
|
|
|
where
|
2020-01-31 21:14:56 -05:00
|
|
|
(mode, cb') = if batchMode
|
|
|
|
then (EGLtLosses True, return ())
|
|
|
|
else (EGLifetime, cb)
|
2019-11-14 02:47:57 -05:00
|
|
|
|
|
|
|
-- | Prompt to edit a goalie's lifetime losses
|
2020-01-02 00:07:29 -05:00
|
|
|
editGoalieLtLossesPrompt
|
|
|
|
:: Bool
|
|
|
|
-- ^ Indicates whether or not we're in batch mode
|
2020-01-31 21:14:56 -05:00
|
|
|
-> Action ()
|
|
|
|
-- ^ Action to perform on completion
|
2020-01-02 00:07:29 -05:00
|
|
|
-> Prompt
|
2020-01-31 21:14:56 -05:00
|
|
|
editGoalieLtLossesPrompt batchMode cb =
|
2020-01-02 00:07:29 -05:00
|
|
|
editNum "Lifetime losses: " mode
|
2020-01-31 21:14:56 -05:00
|
|
|
(gLifetime.gsLosses .~) cb'
|
2020-01-02 00:07:29 -05:00
|
|
|
where
|
2020-01-31 21:14:56 -05:00
|
|
|
(mode, cb') = if batchMode
|
|
|
|
then (EGLtTies, return ())
|
|
|
|
else (EGLifetime, cb)
|
2019-11-14 02:55:50 -05:00
|
|
|
|
|
|
|
-- | Prompt to edit a goalie's lifetime ties
|
2020-01-31 21:14:56 -05:00
|
|
|
editGoalieLtTiesPrompt
|
|
|
|
:: Action ()
|
|
|
|
-- ^ Action to perform on completion
|
|
|
|
-> Prompt
|
2020-01-01 23:36:37 -05:00
|
|
|
editGoalieLtTiesPrompt = editNum "Lifetime ties: " EGLifetime
|
|
|
|
(gLifetime.gsTies .~)
|
|
|
|
|
|
|
|
editNum
|
|
|
|
:: String
|
|
|
|
-> EditGoalieMode
|
|
|
|
-> (Int -> Goalie -> Goalie)
|
2020-01-31 21:14:56 -05:00
|
|
|
-> Action ()
|
2020-01-01 23:36:37 -05:00
|
|
|
-> Prompt
|
2020-01-31 21:14:56 -05:00
|
|
|
editNum pStr mode f cb = numPromptWithFallback pStr
|
|
|
|
(goto mode >> cb)
|
|
|
|
(\num -> do
|
|
|
|
doEdit mode $ f num
|
|
|
|
cb)
|
2020-01-01 23:36:37 -05:00
|
|
|
|
2020-01-09 01:35:37 -05:00
|
|
|
doEdit :: EditGoalieMode -> (Goalie -> Goalie) -> Action ()
|
|
|
|
doEdit mode f = do
|
|
|
|
modify $ editSelectedGoalie f
|
|
|
|
goto mode
|
2020-01-01 23:36:37 -05:00
|
|
|
|
|
|
|
goto :: EditGoalieMode -> Action ()
|
|
|
|
goto = modify . (progMode.editGoalieStateL.egsMode .~)
|