2019-11-01 05:47:13 -04:00
|
|
|
{- |
|
|
|
|
|
|
|
|
mtlstats
|
2020-01-11 00:29:45 -05:00
|
|
|
Copyright (C) 1984, 1985, 2019, 2020 Rhéal Lamothe
|
2019-11-01 05:47:13 -04: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-01 06:10:37 -04:00
|
|
|
module Mtlstats.Prompt.EditPlayer
|
|
|
|
( editPlayerNumPrompt
|
|
|
|
, editPlayerNamePrompt
|
2019-11-01 06:26:38 -04:00
|
|
|
, editPlayerPosPrompt
|
2019-11-01 06:30:37 -04:00
|
|
|
, editPlayerYtdGoalsPrompt
|
2019-11-01 06:33:51 -04:00
|
|
|
, editPlayerYtdAssistsPrompt
|
2019-11-01 06:37:28 -04:00
|
|
|
, editPlayerYtdPMinPrompt
|
2019-11-01 06:40:48 -04:00
|
|
|
, editPlayerLtGoalsPrompt
|
2019-11-01 06:43:39 -04:00
|
|
|
, editPlayerLtAssistsPrompt
|
2019-11-01 06:48:25 -04:00
|
|
|
, editPlayerLtPMinPrompt
|
2019-11-01 06:10:37 -04:00
|
|
|
) where
|
2019-11-01 05:47:13 -04:00
|
|
|
|
2020-01-09 01:15:30 -05:00
|
|
|
import Control.Monad.Trans.State (modify)
|
|
|
|
import Lens.Micro ((.~))
|
2019-11-01 06:06:41 -04:00
|
|
|
|
2020-01-09 01:15:30 -05:00
|
|
|
import Mtlstats.Actions
|
2019-11-01 06:06:41 -04:00
|
|
|
import Mtlstats.Prompt
|
2019-11-01 05:47:13 -04:00
|
|
|
import Mtlstats.Types
|
|
|
|
|
|
|
|
-- | Prompt to edit a player's number
|
|
|
|
editPlayerNumPrompt :: Prompt
|
2019-12-31 23:23:34 -05:00
|
|
|
editPlayerNumPrompt = editNum "Player number: " EPMenu
|
|
|
|
(pNumber .~)
|
2019-11-01 06:10:37 -04:00
|
|
|
|
|
|
|
-- | Prompt to edit a player's name
|
|
|
|
editPlayerNamePrompt :: Prompt
|
2019-12-31 23:23:34 -05:00
|
|
|
editPlayerNamePrompt = namePrompt "Player name: " $ \name ->
|
|
|
|
if null name
|
|
|
|
then goto EPMenu
|
2020-01-09 01:15:30 -05:00
|
|
|
else doEdit EPMenu $ pName .~ name
|
2019-11-01 06:22:48 -04:00
|
|
|
|
2019-11-01 06:26:38 -04:00
|
|
|
-- | Prompt to edit a player's position
|
|
|
|
editPlayerPosPrompt :: Prompt
|
2019-12-31 23:23:34 -05:00
|
|
|
editPlayerPosPrompt = ucStrPrompt "Player position: " $ \pos ->
|
|
|
|
if null pos
|
|
|
|
then goto EPMenu
|
2020-01-09 01:15:30 -05:00
|
|
|
else doEdit EPMenu $ pPosition .~ pos
|
2019-11-01 06:26:38 -04:00
|
|
|
|
2019-11-01 06:30:37 -04:00
|
|
|
-- | Prompt to edit a player's year-to-date goals
|
2020-01-01 22:57:16 -05:00
|
|
|
editPlayerYtdGoalsPrompt
|
|
|
|
:: Bool
|
|
|
|
-- ^ Indicates wheter or not we're editing in batch mode
|
|
|
|
-> Prompt
|
|
|
|
editPlayerYtdGoalsPrompt batchMode = editNum "Year-to-date goals: " mode
|
2019-12-31 23:23:34 -05:00
|
|
|
(pYtd.psGoals .~)
|
2020-01-01 22:57:16 -05:00
|
|
|
where
|
|
|
|
mode = if batchMode then EPYtdAssists True else EPYtd
|
2019-11-01 06:30:37 -04:00
|
|
|
|
2019-11-01 06:33:51 -04:00
|
|
|
-- | Prompt to edit a player's year-to-date assists
|
2020-01-01 22:57:16 -05:00
|
|
|
editPlayerYtdAssistsPrompt
|
|
|
|
:: Bool
|
|
|
|
-- ^ Indicates wheter or not we're editing in batch mode
|
|
|
|
-> Prompt
|
|
|
|
editPlayerYtdAssistsPrompt batchMode = editNum "Year-to-date assists: " mode
|
2019-12-31 23:23:34 -05:00
|
|
|
(pYtd.psAssists .~)
|
2020-01-01 22:57:16 -05:00
|
|
|
where
|
|
|
|
mode = if batchMode then EPYtdPMin else EPYtd
|
2019-11-01 06:33:51 -04:00
|
|
|
|
2019-11-01 06:37:28 -04:00
|
|
|
-- | Prompt to edit a player's year-to-date penalty minutes
|
|
|
|
editPlayerYtdPMinPrompt :: Prompt
|
2019-12-31 23:23:34 -05:00
|
|
|
editPlayerYtdPMinPrompt = editNum "Year-to-date penalty minutes: " EPYtd
|
|
|
|
(pYtd.psPMin .~)
|
2019-11-01 06:37:28 -04:00
|
|
|
|
2019-11-01 06:40:48 -04:00
|
|
|
-- | Prompt to edit a player's lifetime goals
|
2020-01-01 22:57:16 -05:00
|
|
|
editPlayerLtGoalsPrompt
|
|
|
|
:: Bool
|
|
|
|
-- ^ Indicates wheter or not we're editing in batch mode
|
|
|
|
-> Prompt
|
|
|
|
editPlayerLtGoalsPrompt batchMode = editNum "Lifetime goals: " mode
|
2019-12-31 23:23:34 -05:00
|
|
|
(pLifetime.psGoals .~)
|
2020-01-01 22:57:16 -05:00
|
|
|
where
|
|
|
|
mode = if batchMode then EPLtAssists True else EPLifetime
|
2019-11-01 06:40:48 -04:00
|
|
|
|
2019-11-01 06:43:39 -04:00
|
|
|
-- | Prompt to edit a player's lifetime assists
|
2020-01-01 22:57:16 -05:00
|
|
|
editPlayerLtAssistsPrompt
|
|
|
|
:: Bool
|
|
|
|
-- ^ Indicates wheter or not we're editing in batch mode
|
|
|
|
-> Prompt
|
|
|
|
editPlayerLtAssistsPrompt batchMode = editNum "Lifetime assists: " mode
|
2019-12-31 23:23:34 -05:00
|
|
|
(pLifetime.psAssists .~)
|
2020-01-01 22:57:16 -05:00
|
|
|
where
|
|
|
|
mode = if batchMode then EPLtPMin else EPLifetime
|
2019-11-01 06:43:39 -04:00
|
|
|
|
2019-11-01 06:48:25 -04:00
|
|
|
-- | Prompt to edit a player's lifetime penalty minutes
|
|
|
|
editPlayerLtPMinPrompt :: Prompt
|
2019-12-31 23:23:34 -05:00
|
|
|
editPlayerLtPMinPrompt = editNum "Lifetime penalty minutes: " EPLifetime
|
|
|
|
(pLifetime.psPMin .~)
|
|
|
|
|
|
|
|
editNum
|
|
|
|
:: String
|
|
|
|
-> EditPlayerMode
|
|
|
|
-> (Int -> Player -> Player)
|
|
|
|
-> Prompt
|
|
|
|
editNum pStr mode f = numPromptWithFallback pStr
|
|
|
|
(goto mode)
|
2020-01-09 01:15:30 -05:00
|
|
|
(doEdit mode . f)
|
2019-11-01 06:48:25 -04:00
|
|
|
|
2020-01-09 01:15:30 -05:00
|
|
|
doEdit :: EditPlayerMode -> (Player -> Player) -> Action ()
|
|
|
|
doEdit mode f = do
|
|
|
|
modify $ editSelectedPlayer f
|
|
|
|
goto mode
|
2019-12-31 23:23:34 -05:00
|
|
|
|
|
|
|
goto :: EditPlayerMode -> Action ()
|
|
|
|
goto = modify . (progMode.editPlayerStateL.epsMode .~)
|