prompt for player's position

This commit is contained in:
Jonathan Lamothe 2019-09-09 22:57:36 -04:00
parent 57ac90038a
commit 0ee0451496
2 changed files with 18 additions and 3 deletions

View File

@ -54,9 +54,10 @@ dispatch s = case s^.progMode of
| not $ gs^.dataVerified -> verifyDataC
| otherwise -> reportC
CreatePlayer cps
| null $ cps^.cpsNumber -> getPlayerNumC
| null $ cps^.cpsName -> getPlayerNameC
| otherwise -> undefined
| null $ cps^.cpsNumber -> getPlayerNumC
| null $ cps^.cpsName -> getPlayerNameC
| null $ cps^.cpsPosition -> getPlayerPosC
| otherwise -> undefined
mainMenuC :: Controller
mainMenuC = Controller
@ -214,3 +215,11 @@ getPlayerNameC = Controller
promptHandler playerNamePrompt e
return True
}
getPlayerPosC :: Controller
getPlayerPosC = Controller
{ drawController = drawPrompt playerPosPrompt
, handleController = \e -> do
promptHandler playerPosPrompt e
return True
}

View File

@ -33,6 +33,7 @@ module Mtlstats.Prompt (
awayScorePrompt,
playerNumPrompt,
playerNamePrompt,
playerPosPrompt
) where
import Control.Monad (when)
@ -132,5 +133,10 @@ playerNamePrompt :: Prompt
playerNamePrompt = strPrompt "Player name: " $
modify . (progMode.createPlayerStateL.cpsName .~)
-- | Prompts for a new player's position
playerPosPrompt :: Prompt
playerPosPrompt = strPrompt "Player position: " $
modify . (progMode.createPlayerStateL.cpsPosition .~)
drawSimplePrompt :: String -> ProgState -> C.Update ()
drawSimplePrompt pStr s = C.drawString $ pStr ++ s^.inputBuffer