prompt for player number

This commit is contained in:
Jonathan Lamothe 2019-09-09 13:04:39 -04:00
parent 154c3979a5
commit 754b3dd25c
2 changed files with 18 additions and 2 deletions

View File

@ -53,7 +53,9 @@ dispatch s = case s^.progMode of
| null $ gs^.overtimeFlag -> overtimeFlagC
| not $ gs^.dataVerified -> verifyDataC
| otherwise -> reportC
CreatePlayer _ -> undefined
CreatePlayer cps
| null $ cps^.cpsNumber -> getPlayerNumC
| otherwise -> undefined
mainMenuC :: Controller
mainMenuC = Controller
@ -195,3 +197,11 @@ reportC = Controller
header :: ProgState -> C.Update ()
header s = C.drawString $
"*** GAME " ++ padNum 2 (s^.database.dbGames) ++ " ***\n"
getPlayerNumC :: Controller
getPlayerNumC = Controller
{ drawController = drawPrompt playerNumPrompt
, handleController = \e -> do
promptHandler playerNumPrompt e
return True
}

View File

@ -30,7 +30,8 @@ module Mtlstats.Prompt (
gameDayPrompt,
otherTeamPrompt,
homeScorePrompt,
awayScorePrompt
awayScorePrompt,
playerNumPrompt
) where
import Control.Monad (when)
@ -120,5 +121,10 @@ awayScorePrompt :: Prompt
awayScorePrompt = numPrompt "Away score: " $
modify . (progMode.gameStateL.awayScore ?~)
-- | Prompts for a new player's number
playerNumPrompt :: Prompt
playerNumPrompt = numPrompt "Player number: " $
modify . (progMode.createPlayerStateL.cpsNumber ?~)
drawSimplePrompt :: String -> ProgState -> C.Update ()
drawSimplePrompt pStr s = C.drawString $ pStr ++ s^.inputBuffer