From fefa217df11faffd08d5485669b6d4939db0bc95 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 13 Feb 2020 02:55:51 -0500 Subject: [PATCH] implemented Mtlstats.Control.CreatePlayer.getRookieFlagC ...also refactored some other controllers to use promptController --- src/Mtlstats/Control/CreatePlayer.hs | 34 ++++++++++++---------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/Mtlstats/Control/CreatePlayer.hs b/src/Mtlstats/Control/CreatePlayer.hs index 01b8275..9283d1a 100644 --- a/src/Mtlstats/Control/CreatePlayer.hs +++ b/src/Mtlstats/Control/CreatePlayer.hs @@ -35,32 +35,28 @@ 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 + | null $ cps^.cpsNumber = getPlayerNumC + | null $ cps^.cpsName = getPlayerNameC + | null $ cps^.cpsPosition = getPlayerPosC + | null $ cps^.cpsRookieFlag = getRookieFlagC + | otherwise = confirmCreatePlayerC getPlayerNumC :: Controller -getPlayerNumC = Controller - { drawController = drawPrompt playerNumPrompt - , handleController = \e -> do - promptHandler playerNumPrompt e - return True - } +getPlayerNumC = promptController playerNumPrompt getPlayerNameC :: Controller -getPlayerNameC = Controller - { drawController = drawPrompt playerNamePrompt - , handleController = \e -> do - promptHandler playerNamePrompt e - return True - } +getPlayerNameC = promptController playerNamePrompt getPlayerPosC :: Controller -getPlayerPosC = Controller - { drawController = drawPrompt playerPosPrompt +getPlayerPosC = promptController playerPosPrompt + +getRookieFlagC :: Controller +getRookieFlagC = Controller + { drawController = const $ do + C.drawString "Is this player a rookie? (Y/N)" + return C.CursorInvisible , handleController = \e -> do - promptHandler playerPosPrompt e + modify $ progMode.createPlayerStateL.cpsRookieFlag .~ ynHandler e return True }