implement player edit menu
This commit is contained in:
parent
5bb4e509b8
commit
0194f68996
|
@ -21,10 +21,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
module Mtlstats.Control.EditPlayer (editPlayerC) where
|
module Mtlstats.Control.EditPlayer (editPlayerC) where
|
||||||
|
|
||||||
|
import Data.Maybe (fromMaybe)
|
||||||
import Lens.Micro ((^.))
|
import Lens.Micro ((^.))
|
||||||
|
import qualified UI.NCurses as C
|
||||||
|
|
||||||
|
import Mtlstats.Menu
|
||||||
import Mtlstats.Prompt
|
import Mtlstats.Prompt
|
||||||
import Mtlstats.Types
|
import Mtlstats.Types
|
||||||
|
import Mtlstats.Util
|
||||||
|
|
||||||
-- | Dispatcher/controller for the player edit mode
|
-- | Dispatcher/controller for the player edit mode
|
||||||
editPlayerC :: EditPlayerState -> Controller
|
editPlayerC :: EditPlayerState -> Controller
|
||||||
|
@ -51,7 +55,19 @@ selectPlayerC = Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
menuC :: Controller
|
menuC :: Controller
|
||||||
menuC = undefined
|
menuC = Controller
|
||||||
|
{ drawController = \s -> do
|
||||||
|
let
|
||||||
|
header = fromMaybe "" $ do
|
||||||
|
pid <- s^.progMode.editPlayerStateL.epsSelectedPlayer
|
||||||
|
p <- nth pid $ s^.database.dbPlayers
|
||||||
|
Just $ playerDetails p ++ "\n"
|
||||||
|
C.drawString header
|
||||||
|
drawMenu editPlayerMenu
|
||||||
|
, handleController = \e -> do
|
||||||
|
menuHandler editPlayerMenu e
|
||||||
|
return True
|
||||||
|
}
|
||||||
|
|
||||||
numberC :: Controller
|
numberC :: Controller
|
||||||
numberC = undefined
|
numberC = undefined
|
||||||
|
|
|
@ -27,7 +27,8 @@ module Mtlstats.Menu (
|
||||||
mainMenu,
|
mainMenu,
|
||||||
newSeasonMenu,
|
newSeasonMenu,
|
||||||
gameMonthMenu,
|
gameMonthMenu,
|
||||||
gameTypeMenu
|
gameTypeMenu,
|
||||||
|
editPlayerMenu
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad.IO.Class (liftIO)
|
import Control.Monad.IO.Class (liftIO)
|
||||||
|
@ -123,3 +124,21 @@ gameTypeMenu = Menu "Game type:" ()
|
||||||
, MenuItem '2' "Away Game" $
|
, MenuItem '2' "Away Game" $
|
||||||
modify $ progMode.gameStateL.gameType ?~ AwayGame
|
modify $ progMode.gameStateL.gameType ?~ AwayGame
|
||||||
]
|
]
|
||||||
|
|
||||||
|
-- | The player edit menu
|
||||||
|
editPlayerMenu :: Menu ()
|
||||||
|
editPlayerMenu = Menu "*** EDIT PLAYER ***" () $ map
|
||||||
|
(\(ch, label, mode) -> MenuItem ch label $ case mode of
|
||||||
|
Nothing -> modify $ progMode .~ MainMenu
|
||||||
|
Just m -> modify $ progMode.editPlayerStateL.epsMode .~ m)
|
||||||
|
[ ( '1', "Change number", Just EPNumber )
|
||||||
|
, ( '2', "Change name", Just EPName )
|
||||||
|
, ( '3', "Change position", Just EPPosition )
|
||||||
|
, ( '4', "YTD goals", Just EPYtdGoals )
|
||||||
|
, ( '5', "YTD assists", Just EPYtdAssists )
|
||||||
|
, ( '6', "YTD penalty mins", Just EPYtdPMin )
|
||||||
|
, ( '7', "Lifetime goals", Just EPLtGoals )
|
||||||
|
, ( '8', "Lifetime assists", Just EPLtAssists )
|
||||||
|
, ( '9', "Lifetime penalty mins", Just EPLtPMin )
|
||||||
|
, ( '0', "Finished editing", Nothing )
|
||||||
|
]
|
||||||
|
|
|
@ -153,6 +153,7 @@ module Mtlstats.Types (
|
||||||
playerSearchExact,
|
playerSearchExact,
|
||||||
modifyPlayer,
|
modifyPlayer,
|
||||||
playerSummary,
|
playerSummary,
|
||||||
|
playerDetails,
|
||||||
playerIsActive,
|
playerIsActive,
|
||||||
-- ** PlayerStats Helpers
|
-- ** PlayerStats Helpers
|
||||||
psPoints,
|
psPoints,
|
||||||
|
@ -860,6 +861,10 @@ playerSummary :: Player -> String
|
||||||
playerSummary p =
|
playerSummary p =
|
||||||
p^.pName ++ " (" ++ show (p^.pNumber) ++ ") " ++ p^.pPosition
|
p^.pName ++ " (" ++ show (p^.pNumber) ++ ") " ++ p^.pPosition
|
||||||
|
|
||||||
|
-- | Provides a detailed string describing a 'Player'
|
||||||
|
playerDetails :: Player -> String
|
||||||
|
playerDetails = undefined
|
||||||
|
|
||||||
-- | Determines whether or not a player has been active in the current
|
-- | Determines whether or not a player has been active in the current
|
||||||
-- season/year
|
-- season/year
|
||||||
playerIsActive :: Player -> Bool
|
playerIsActive :: Player -> Bool
|
||||||
|
|
Loading…
Reference in New Issue
Block a user