Merge pull request #67 from mtlstats/lifetime-new-player
Lifetime new player
This commit is contained in:
commit
378efea24e
|
@ -1,5 +1,8 @@
|
||||||
# Changelog for mtlstats
|
# Changelog for mtlstats
|
||||||
|
|
||||||
|
## current
|
||||||
|
- Edit lifetime stats on new player creation
|
||||||
|
|
||||||
## 0.11.0
|
## 0.11.0
|
||||||
- Added active flag to players/goalies
|
- Added active flag to players/goalies
|
||||||
- Clear rookie flag on new (regular) season
|
- Clear rookie flag on new (regular) season
|
||||||
|
|
|
@ -25,15 +25,15 @@ import Control.Monad (join)
|
||||||
import Control.Monad.Trans.State (gets, modify)
|
import Control.Monad.Trans.State (gets, modify)
|
||||||
import Data.Maybe (fromJust)
|
import Data.Maybe (fromJust)
|
||||||
import Lens.Micro ((^.))
|
import Lens.Micro ((^.))
|
||||||
import Lens.Micro.Extras (view)
|
|
||||||
import qualified UI.NCurses as C
|
import qualified UI.NCurses as C
|
||||||
|
|
||||||
import Mtlstats.Actions
|
import Mtlstats.Actions
|
||||||
import Mtlstats.Control.TitleScreen
|
import Mtlstats.Control.CreatePlayer
|
||||||
import Mtlstats.Control.EditGoalie
|
import Mtlstats.Control.EditGoalie
|
||||||
import Mtlstats.Control.EditPlayer
|
import Mtlstats.Control.EditPlayer
|
||||||
import Mtlstats.Control.EditStandings
|
import Mtlstats.Control.EditStandings
|
||||||
import Mtlstats.Control.NewGame
|
import Mtlstats.Control.NewGame
|
||||||
|
import Mtlstats.Control.TitleScreen
|
||||||
import Mtlstats.Handlers
|
import Mtlstats.Handlers
|
||||||
import Mtlstats.Menu
|
import Mtlstats.Menu
|
||||||
import Mtlstats.Prompt
|
import Mtlstats.Prompt
|
||||||
|
@ -43,16 +43,12 @@ import Mtlstats.Types
|
||||||
-- run
|
-- run
|
||||||
dispatch :: ProgState -> Controller
|
dispatch :: ProgState -> Controller
|
||||||
dispatch s = case s^.progMode of
|
dispatch s = case s^.progMode of
|
||||||
TitleScreen -> titleScreenC
|
TitleScreen -> titleScreenC
|
||||||
MainMenu -> mainMenuC
|
MainMenu -> mainMenuC
|
||||||
NewSeason flag -> newSeasonC flag
|
NewSeason flag -> newSeasonC flag
|
||||||
NewGame gs -> newGameC gs
|
NewGame gs -> newGameC gs
|
||||||
EditMenu -> editMenuC
|
EditMenu -> editMenuC
|
||||||
CreatePlayer cps
|
CreatePlayer cps -> createPlayerC cps
|
||||||
| null $ cps^.cpsNumber -> getPlayerNumC
|
|
||||||
| null $ cps^.cpsName -> getPlayerNameC
|
|
||||||
| null $ cps^.cpsPosition -> getPlayerPosC
|
|
||||||
| otherwise -> confirmCreatePlayerC
|
|
||||||
CreateGoalie cgs
|
CreateGoalie cgs
|
||||||
| null $ cgs^.cgsNumber -> getGoalieNumC
|
| null $ cgs^.cgsNumber -> getGoalieNumC
|
||||||
| null $ cgs^.cgsName -> getGoalieNameC
|
| null $ cgs^.cgsName -> getGoalieNameC
|
||||||
|
@ -74,50 +70,6 @@ newSeasonC True = menuController newSeasonMenu
|
||||||
editMenuC :: Controller
|
editMenuC :: Controller
|
||||||
editMenuC = menuController editMenu
|
editMenuC = menuController editMenu
|
||||||
|
|
||||||
getPlayerNumC :: Controller
|
|
||||||
getPlayerNumC = Controller
|
|
||||||
{ drawController = drawPrompt playerNumPrompt
|
|
||||||
, handleController = \e -> do
|
|
||||||
promptHandler playerNumPrompt e
|
|
||||||
return True
|
|
||||||
}
|
|
||||||
|
|
||||||
getPlayerNameC :: Controller
|
|
||||||
getPlayerNameC = Controller
|
|
||||||
{ drawController = drawPrompt playerNamePrompt
|
|
||||||
, handleController = \e -> do
|
|
||||||
promptHandler playerNamePrompt e
|
|
||||||
return True
|
|
||||||
}
|
|
||||||
|
|
||||||
getPlayerPosC :: Controller
|
|
||||||
getPlayerPosC = Controller
|
|
||||||
{ drawController = drawPrompt playerPosPrompt
|
|
||||||
, handleController = \e -> do
|
|
||||||
promptHandler playerPosPrompt e
|
|
||||||
return True
|
|
||||||
}
|
|
||||||
|
|
||||||
confirmCreatePlayerC :: Controller
|
|
||||||
confirmCreatePlayerC = Controller
|
|
||||||
{ drawController = \s -> do
|
|
||||||
let cps = s^.progMode.createPlayerStateL
|
|
||||||
C.drawString $ " Player number: " ++ show (fromJust $ cps^.cpsNumber) ++ "\n"
|
|
||||||
C.drawString $ " Player name: " ++ cps^.cpsName ++ "\n"
|
|
||||||
C.drawString $ "Player position: " ++ cps^.cpsPosition ++ "\n\n"
|
|
||||||
C.drawString "Create player: are you sure? (Y/N)"
|
|
||||||
return C.CursorInvisible
|
|
||||||
, handleController = \e -> do
|
|
||||||
case ynHandler e of
|
|
||||||
Just True -> do
|
|
||||||
modify addPlayer
|
|
||||||
join $ gets $ view $ progMode.createPlayerStateL.cpsSuccessCallback
|
|
||||||
Just False ->
|
|
||||||
join $ gets $ view $ progMode.createPlayerStateL.cpsFailureCallback
|
|
||||||
Nothing -> return ()
|
|
||||||
return True
|
|
||||||
}
|
|
||||||
|
|
||||||
getGoalieNumC :: Controller
|
getGoalieNumC :: Controller
|
||||||
getGoalieNumC = Controller
|
getGoalieNumC = Controller
|
||||||
{ drawController = drawPrompt goalieNumPrompt
|
{ drawController = drawPrompt goalieNumPrompt
|
||||||
|
|
|
@ -0,0 +1,91 @@
|
||||||
|
{- |
|
||||||
|
|
||||||
|
mtlstats
|
||||||
|
Copyright (C) 1984, 1985, 2019, 2020 Rhéal Lamothe
|
||||||
|
<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/>.
|
||||||
|
|
||||||
|
-}
|
||||||
|
|
||||||
|
module Mtlstats.Control.CreatePlayer (createPlayerC) where
|
||||||
|
|
||||||
|
import Control.Monad (join)
|
||||||
|
import Control.Monad.Trans.State (gets, modify)
|
||||||
|
import Data.Maybe (fromJust)
|
||||||
|
import Lens.Micro ((^.), (.~), (?~), (%~), to)
|
||||||
|
import qualified UI.NCurses as C
|
||||||
|
|
||||||
|
import Mtlstats.Actions
|
||||||
|
import Mtlstats.Handlers
|
||||||
|
import Mtlstats.Prompt
|
||||||
|
import Mtlstats.Types
|
||||||
|
|
||||||
|
-- | Handles player creation
|
||||||
|
createPlayerC :: CreatePlayerState -> Controller
|
||||||
|
createPlayerC cps
|
||||||
|
| null $ cps^.cpsNumber = getPlayerNumC
|
||||||
|
| null $ cps^.cpsName = getPlayerNameC
|
||||||
|
| null $ cps^.cpsPosition = getPlayerPosC
|
||||||
|
| otherwise = confirmCreatePlayerC
|
||||||
|
|
||||||
|
getPlayerNumC :: Controller
|
||||||
|
getPlayerNumC = Controller
|
||||||
|
{ drawController = drawPrompt playerNumPrompt
|
||||||
|
, handleController = \e -> do
|
||||||
|
promptHandler playerNumPrompt e
|
||||||
|
return True
|
||||||
|
}
|
||||||
|
|
||||||
|
getPlayerNameC :: Controller
|
||||||
|
getPlayerNameC = Controller
|
||||||
|
{ drawController = drawPrompt playerNamePrompt
|
||||||
|
, handleController = \e -> do
|
||||||
|
promptHandler playerNamePrompt e
|
||||||
|
return True
|
||||||
|
}
|
||||||
|
|
||||||
|
getPlayerPosC :: Controller
|
||||||
|
getPlayerPosC = Controller
|
||||||
|
{ drawController = drawPrompt playerPosPrompt
|
||||||
|
, handleController = \e -> do
|
||||||
|
promptHandler playerPosPrompt e
|
||||||
|
return True
|
||||||
|
}
|
||||||
|
|
||||||
|
confirmCreatePlayerC :: Controller
|
||||||
|
confirmCreatePlayerC = Controller
|
||||||
|
{ drawController = \s -> do
|
||||||
|
let cps = s^.progMode.createPlayerStateL
|
||||||
|
C.drawString $ " Player number: " ++ show (fromJust $ cps^.cpsNumber) ++ "\n"
|
||||||
|
C.drawString $ " Player name: " ++ cps^.cpsName ++ "\n"
|
||||||
|
C.drawString $ "Player position: " ++ cps^.cpsPosition ++ "\n\n"
|
||||||
|
C.drawString "Create player: are you sure? (Y/N)"
|
||||||
|
return C.CursorInvisible
|
||||||
|
, handleController = \e -> do
|
||||||
|
case ynHandler e of
|
||||||
|
Just True -> do
|
||||||
|
pid <- gets (^.database.dbPlayers.to length)
|
||||||
|
cb <- gets (^.progMode.createPlayerStateL.cpsSuccessCallback)
|
||||||
|
modify
|
||||||
|
$ (progMode.editPlayerStateL
|
||||||
|
%~ (epsSelectedPlayer ?~ pid)
|
||||||
|
. (epsMode .~ EPLtGoals True)
|
||||||
|
. (epsCallback .~ cb))
|
||||||
|
. addPlayer
|
||||||
|
Just False ->
|
||||||
|
join $ gets (^.progMode.createPlayerStateL.cpsFailureCallback)
|
||||||
|
Nothing -> return ()
|
||||||
|
return True
|
||||||
|
}
|
|
@ -37,58 +37,64 @@ import Mtlstats.Util
|
||||||
editPlayerC :: EditPlayerState -> Controller
|
editPlayerC :: EditPlayerState -> Controller
|
||||||
editPlayerC eps
|
editPlayerC eps
|
||||||
| null $ eps^.epsSelectedPlayer = selectPlayerC
|
| null $ eps^.epsSelectedPlayer = selectPlayerC
|
||||||
| otherwise = case eps^.epsMode of
|
| otherwise =
|
||||||
EPMenu -> menuC
|
( case eps^.epsMode of
|
||||||
EPNumber -> numberC
|
EPMenu -> menuC
|
||||||
EPName -> nameC
|
EPNumber -> numberC
|
||||||
EPPosition -> positionC
|
EPName -> nameC
|
||||||
EPYtd -> ytdC
|
EPPosition -> positionC
|
||||||
EPLifetime -> lifetimeC
|
EPYtd -> ytdC
|
||||||
EPYtdGoals b -> ytdGoalsC b
|
EPLifetime -> lifetimeC
|
||||||
EPYtdAssists b -> ytdAssistsC b
|
EPYtdGoals b -> ytdGoalsC b
|
||||||
EPYtdPMin -> ytdPMinC
|
EPYtdAssists b -> ytdAssistsC b
|
||||||
EPLtGoals b -> ltGoalsC b
|
EPYtdPMin -> ytdPMinC
|
||||||
EPLtAssists b -> ltAssistsC b
|
EPLtGoals b -> ltGoalsC b
|
||||||
EPLtPMin -> ltPMinC
|
EPLtAssists b -> ltAssistsC b
|
||||||
|
EPLtPMin -> ltPMinC
|
||||||
|
) $ eps^.epsCallback
|
||||||
|
|
||||||
selectPlayerC :: Controller
|
selectPlayerC :: Controller
|
||||||
selectPlayerC = promptController playerToEditPrompt
|
selectPlayerC = promptController playerToEditPrompt
|
||||||
|
|
||||||
menuC :: Controller
|
menuC :: Action () -> Controller
|
||||||
menuC = menuControllerWith header editPlayerMenu
|
menuC _ = menuControllerWith header editPlayerMenu
|
||||||
|
|
||||||
numberC :: Controller
|
numberC :: Action () -> Controller
|
||||||
numberC = promptController editPlayerNumPrompt
|
numberC = promptController . editPlayerNumPrompt
|
||||||
|
|
||||||
nameC :: Controller
|
nameC :: Action () -> Controller
|
||||||
nameC = promptController editPlayerNamePrompt
|
nameC = promptController . editPlayerNamePrompt
|
||||||
|
|
||||||
positionC :: Controller
|
positionC :: Action () -> Controller
|
||||||
positionC = promptController editPlayerPosPrompt
|
positionC = promptController . editPlayerPosPrompt
|
||||||
|
|
||||||
ytdC :: Controller
|
ytdC :: Action () -> Controller
|
||||||
ytdC = menuControllerWith header editPlayerYtdMenu
|
ytdC _ = menuControllerWith header editPlayerYtdMenu
|
||||||
|
|
||||||
lifetimeC :: Controller
|
lifetimeC :: Action () -> Controller
|
||||||
lifetimeC = menuControllerWith header editPlayerLtMenu
|
lifetimeC _ = menuControllerWith header editPlayerLtMenu
|
||||||
|
|
||||||
ytdGoalsC :: Bool -> Controller
|
ytdGoalsC :: Bool -> Action () -> Controller
|
||||||
ytdGoalsC = promptController . editPlayerYtdGoalsPrompt
|
ytdGoalsC batchMode callback = promptController $
|
||||||
|
editPlayerYtdGoalsPrompt batchMode callback
|
||||||
|
|
||||||
ytdAssistsC :: Bool -> Controller
|
ytdAssistsC :: Bool -> Action () -> Controller
|
||||||
ytdAssistsC = promptController . editPlayerYtdAssistsPrompt
|
ytdAssistsC batchMode callback = promptController $
|
||||||
|
editPlayerYtdAssistsPrompt batchMode callback
|
||||||
|
|
||||||
ytdPMinC :: Controller
|
ytdPMinC :: Action () -> Controller
|
||||||
ytdPMinC = promptController editPlayerYtdPMinPrompt
|
ytdPMinC = promptController . editPlayerYtdPMinPrompt
|
||||||
|
|
||||||
ltGoalsC :: Bool -> Controller
|
ltGoalsC :: Bool -> Action () -> Controller
|
||||||
ltGoalsC = promptController . editPlayerLtGoalsPrompt
|
ltGoalsC batchMode callback = promptController $
|
||||||
|
editPlayerLtGoalsPrompt batchMode callback
|
||||||
|
|
||||||
ltAssistsC :: Bool -> Controller
|
ltAssistsC :: Bool -> Action () -> Controller
|
||||||
ltAssistsC = promptController . editPlayerLtAssistsPrompt
|
ltAssistsC batchMode callback = promptController $
|
||||||
|
editPlayerLtAssistsPrompt batchMode callback
|
||||||
|
|
||||||
ltPMinC :: Controller
|
ltPMinC :: Action () -> Controller
|
||||||
ltPMinC = promptController editPlayerLtPMinPrompt
|
ltPMinC = promptController . editPlayerLtPMinPrompt
|
||||||
|
|
||||||
header :: ProgState -> C.Update ()
|
header :: ProgState -> C.Update ()
|
||||||
header s = C.drawString $ fromMaybe "" $ do
|
header s = C.drawString $ fromMaybe "" $ do
|
||||||
|
|
|
@ -39,46 +39,68 @@ import Mtlstats.Prompt
|
||||||
import Mtlstats.Types
|
import Mtlstats.Types
|
||||||
|
|
||||||
-- | Prompt to edit a player's number
|
-- | Prompt to edit a player's number
|
||||||
editPlayerNumPrompt :: Prompt
|
editPlayerNumPrompt
|
||||||
|
:: Action ()
|
||||||
|
-- ^ The action to be performed upon completion
|
||||||
|
-> Prompt
|
||||||
editPlayerNumPrompt = editNum "Player number: " EPMenu
|
editPlayerNumPrompt = editNum "Player number: " EPMenu
|
||||||
(pNumber .~)
|
(pNumber .~)
|
||||||
|
|
||||||
-- | Prompt to edit a player's name
|
-- | Prompt to edit a player's name
|
||||||
editPlayerNamePrompt :: Prompt
|
editPlayerNamePrompt
|
||||||
editPlayerNamePrompt = namePrompt "Player name: " $ \name ->
|
:: Action ()
|
||||||
|
-- ^ The action to be performed upon completion
|
||||||
|
-> Prompt
|
||||||
|
editPlayerNamePrompt callback = namePrompt "Player name: " $ \name -> do
|
||||||
if null name
|
if null name
|
||||||
then goto EPMenu
|
then goto EPMenu
|
||||||
else doEdit EPMenu $ pName .~ name
|
else doEdit EPMenu $ pName .~ name
|
||||||
|
callback
|
||||||
|
|
||||||
-- | Prompt to edit a player's position
|
-- | Prompt to edit a player's position
|
||||||
editPlayerPosPrompt :: Prompt
|
editPlayerPosPrompt
|
||||||
editPlayerPosPrompt = ucStrPrompt "Player position: " $ \pos ->
|
:: Action ()
|
||||||
|
-- ^ The action to be performed upon completion
|
||||||
|
-> Prompt
|
||||||
|
editPlayerPosPrompt callback = ucStrPrompt "Player position: " $ \pos -> do
|
||||||
if null pos
|
if null pos
|
||||||
then goto EPMenu
|
then goto EPMenu
|
||||||
else doEdit EPMenu $ pPosition .~ pos
|
else doEdit EPMenu $ pPosition .~ pos
|
||||||
|
callback
|
||||||
|
|
||||||
-- | Prompt to edit a player's year-to-date goals
|
-- | Prompt to edit a player's year-to-date goals
|
||||||
editPlayerYtdGoalsPrompt
|
editPlayerYtdGoalsPrompt
|
||||||
:: Bool
|
:: Bool
|
||||||
-- ^ Indicates wheter or not we're editing in batch mode
|
-- ^ Indicates wheter or not we're editing in batch mode
|
||||||
|
-> Action ()
|
||||||
|
-- ^ The action to be performed upon completion
|
||||||
-> Prompt
|
-> Prompt
|
||||||
editPlayerYtdGoalsPrompt batchMode = editNum "Year-to-date goals: " mode
|
editPlayerYtdGoalsPrompt batchMode callback = editNum "Year-to-date goals: " mode
|
||||||
(pYtd.psGoals .~)
|
(pYtd.psGoals .~) callback'
|
||||||
where
|
where
|
||||||
mode = if batchMode then EPYtdAssists True else EPYtd
|
(mode, callback') = if batchMode
|
||||||
|
then (EPYtdAssists True, return ())
|
||||||
|
else (EPYtd, callback)
|
||||||
|
|
||||||
-- | Prompt to edit a player's year-to-date assists
|
-- | Prompt to edit a player's year-to-date assists
|
||||||
editPlayerYtdAssistsPrompt
|
editPlayerYtdAssistsPrompt
|
||||||
:: Bool
|
:: Bool
|
||||||
-- ^ Indicates wheter or not we're editing in batch mode
|
-- ^ Indicates wheter or not we're editing in batch mode
|
||||||
|
-> Action ()
|
||||||
|
-- ^ The action to be performed upon completion
|
||||||
-> Prompt
|
-> Prompt
|
||||||
editPlayerYtdAssistsPrompt batchMode = editNum "Year-to-date assists: " mode
|
editPlayerYtdAssistsPrompt batchMode callback = editNum "Year-to-date assists: " mode
|
||||||
(pYtd.psAssists .~)
|
(pYtd.psAssists .~) callback'
|
||||||
where
|
where
|
||||||
mode = if batchMode then EPYtdPMin else EPYtd
|
(mode, callback') = if batchMode
|
||||||
|
then (EPYtdPMin, return ())
|
||||||
|
else (EPYtd, callback)
|
||||||
|
|
||||||
-- | 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
|
||||||
|
:: Action ()
|
||||||
|
-- ^ The action to be performed upon completion
|
||||||
|
-> Prompt
|
||||||
editPlayerYtdPMinPrompt = editNum "Year-to-date penalty minutes: " EPYtd
|
editPlayerYtdPMinPrompt = editNum "Year-to-date penalty minutes: " EPYtd
|
||||||
(pYtd.psPMin .~)
|
(pYtd.psPMin .~)
|
||||||
|
|
||||||
|
@ -86,24 +108,35 @@ editPlayerYtdPMinPrompt = editNum "Year-to-date penalty minutes: " EPYtd
|
||||||
editPlayerLtGoalsPrompt
|
editPlayerLtGoalsPrompt
|
||||||
:: Bool
|
:: Bool
|
||||||
-- ^ Indicates wheter or not we're editing in batch mode
|
-- ^ Indicates wheter or not we're editing in batch mode
|
||||||
|
-> Action ()
|
||||||
|
-- ^ The action to be performed upon completion
|
||||||
-> Prompt
|
-> Prompt
|
||||||
editPlayerLtGoalsPrompt batchMode = editNum "Lifetime goals: " mode
|
editPlayerLtGoalsPrompt batchMode callback = editNum "Lifetime goals: " mode
|
||||||
(pLifetime.psGoals .~)
|
(pLifetime.psGoals .~) callback'
|
||||||
where
|
where
|
||||||
mode = if batchMode then EPLtAssists True else EPLifetime
|
(mode, callback') = if batchMode
|
||||||
|
then (EPLtAssists True, return ())
|
||||||
|
else (EPLifetime, callback)
|
||||||
|
|
||||||
-- | Prompt to edit a player's lifetime assists
|
-- | Prompt to edit a player's lifetime assists
|
||||||
editPlayerLtAssistsPrompt
|
editPlayerLtAssistsPrompt
|
||||||
:: Bool
|
:: Bool
|
||||||
-- ^ Indicates wheter or not we're editing in batch mode
|
-- ^ Indicates wheter or not we're editing in batch mode
|
||||||
|
-> Action ()
|
||||||
|
-- ^ The action to be performed upon completion
|
||||||
-> Prompt
|
-> Prompt
|
||||||
editPlayerLtAssistsPrompt batchMode = editNum "Lifetime assists: " mode
|
editPlayerLtAssistsPrompt batchMode callback = editNum "Lifetime assists: " mode
|
||||||
(pLifetime.psAssists .~)
|
(pLifetime.psAssists .~) callback'
|
||||||
where
|
where
|
||||||
mode = if batchMode then EPLtPMin else EPLifetime
|
(mode, callback') = if batchMode
|
||||||
|
then (EPLtPMin, return ())
|
||||||
|
else (EPLifetime, callback)
|
||||||
|
|
||||||
-- | Prompt to edit a player's lifetime penalty minutes
|
-- | Prompt to edit a player's lifetime penalty minutes
|
||||||
editPlayerLtPMinPrompt :: Prompt
|
editPlayerLtPMinPrompt
|
||||||
|
:: Action ()
|
||||||
|
-- ^ The action to be performed upon completion
|
||||||
|
-> Prompt
|
||||||
editPlayerLtPMinPrompt = editNum "Lifetime penalty minutes: " EPLifetime
|
editPlayerLtPMinPrompt = editNum "Lifetime penalty minutes: " EPLifetime
|
||||||
(pLifetime.psPMin .~)
|
(pLifetime.psPMin .~)
|
||||||
|
|
||||||
|
@ -111,10 +144,13 @@ editNum
|
||||||
:: String
|
:: String
|
||||||
-> EditPlayerMode
|
-> EditPlayerMode
|
||||||
-> (Int -> Player -> Player)
|
-> (Int -> Player -> Player)
|
||||||
|
-> Action ()
|
||||||
-> Prompt
|
-> Prompt
|
||||||
editNum pStr mode f = numPromptWithFallback pStr
|
editNum pStr mode f callback = numPromptWithFallback pStr
|
||||||
(goto mode)
|
(goto mode >> callback)
|
||||||
(doEdit mode . f)
|
(\num -> do
|
||||||
|
doEdit mode $ f num
|
||||||
|
callback)
|
||||||
|
|
||||||
doEdit :: EditPlayerMode -> (Player -> Player) -> Action ()
|
doEdit :: EditPlayerMode -> (Player -> Player) -> Action ()
|
||||||
doEdit mode f = do
|
doEdit mode f = do
|
||||||
|
|
|
@ -98,6 +98,7 @@ module Mtlstats.Types (
|
||||||
-- ** EditPlayerState Lenses
|
-- ** EditPlayerState Lenses
|
||||||
epsSelectedPlayer,
|
epsSelectedPlayer,
|
||||||
epsMode,
|
epsMode,
|
||||||
|
epsCallback,
|
||||||
-- ** EditGoalieState Lenses
|
-- ** EditGoalieState Lenses
|
||||||
egsSelectedGoalie,
|
egsSelectedGoalie,
|
||||||
egsMode,
|
egsMode,
|
||||||
|
@ -350,6 +351,8 @@ data EditPlayerState = EditPlayerState
|
||||||
-- ^ The index number of the player being edited
|
-- ^ The index number of the player being edited
|
||||||
, _epsMode :: EditPlayerMode
|
, _epsMode :: EditPlayerMode
|
||||||
-- ^ The editing mode
|
-- ^ The editing mode
|
||||||
|
, _epsCallback :: Action ()
|
||||||
|
-- ^ The action to perform when the edit is complete
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | Player editing mode
|
-- | Player editing mode
|
||||||
|
@ -818,6 +821,7 @@ newEditPlayerState :: EditPlayerState
|
||||||
newEditPlayerState = EditPlayerState
|
newEditPlayerState = EditPlayerState
|
||||||
{ _epsSelectedPlayer = Nothing
|
{ _epsSelectedPlayer = Nothing
|
||||||
, _epsMode = EPMenu
|
, _epsMode = EPMenu
|
||||||
|
, _epsCallback = return ()
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | Constructor for an 'EditGoalieState' value
|
-- | Constructor for an 'EditGoalieState' value
|
||||||
|
|
Loading…
Reference in New Issue
Block a user