implemented player confirmation/addition

This commit is contained in:
Jonathan Lamothe
2019-09-09 23:35:28 -04:00
parent 0ee0451496
commit 375e87a49e
3 changed files with 58 additions and 0 deletions

View File

@@ -57,6 +57,7 @@ dispatch s = case s^.progMode of
| null $ cps^.cpsNumber -> getPlayerNumC
| null $ cps^.cpsName -> getPlayerNameC
| null $ cps^.cpsPosition -> getPlayerPosC
| not $ cps^.cpsConfirmed -> confirmCreatePlayerC
| otherwise -> undefined
mainMenuC :: Controller
@@ -223,3 +224,22 @@ getPlayerPosC = Controller
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
modify $ progMode .~ MainMenu
Just False -> modify $ progMode .~ MainMenu
Nothing -> return ()
return True
}