prompt user if game went into overtime when necessary
This commit is contained in:
parent
3c8302174b
commit
45427a050e
|
@ -24,6 +24,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
module Mtlstats.Events (handleEvent) where
|
||||
|
||||
import Control.Monad.Trans.State (gets, modify)
|
||||
import Data.Char (toUpper)
|
||||
import Lens.Micro ((^.), (.~))
|
||||
import Lens.Micro.Extras (view)
|
||||
import qualified UI.NCurses as C
|
||||
|
@ -55,4 +56,14 @@ handleEvent e = gets (view progMode) >>= \case
|
|||
promptHandler awayScorePrompt e
|
||||
modify overtimeCheck
|
||||
return True
|
||||
| null $ gs ^. overtimeFlag -> do
|
||||
overtimePrompt e
|
||||
>>= modify . (progMode.gameStateL.overtimeFlag .~)
|
||||
return True
|
||||
| otherwise -> undefined
|
||||
|
||||
overtimePrompt :: C.Event -> Action (Maybe Bool)
|
||||
overtimePrompt (C.EventCharacter c) = case toUpper c of
|
||||
'Y' -> return (Just True)
|
||||
'N' -> return (Just False)
|
||||
_ -> return Nothing
|
||||
|
|
|
@ -40,10 +40,16 @@ draw s = do
|
|||
MainMenu -> drawMenu mainMenu
|
||||
NewSeason -> drawMenu newSeasonMenu
|
||||
NewGame gs
|
||||
| null $ gs ^. gameType -> drawMenu gameTypeMenu
|
||||
| null $ gs ^. otherTeam -> drawPrompt otherTeamPrompt s
|
||||
| null $ gs ^. homeScore -> drawPrompt homeScorePrompt s
|
||||
| null $ gs ^. awayScore -> drawPrompt awayScorePrompt s
|
||||
| otherwise -> undefined
|
||||
| null $ gs^.gameType -> drawMenu gameTypeMenu
|
||||
| null $ gs^.otherTeam -> drawPrompt otherTeamPrompt s
|
||||
| null $ gs^.homeScore -> drawPrompt homeScorePrompt s
|
||||
| null $ gs^.awayScore -> drawPrompt awayScorePrompt s
|
||||
| null $ gs^.overtimeFlag -> overtimePrompt
|
||||
| otherwise -> undefined
|
||||
C.render
|
||||
void $ C.setCursorMode cm
|
||||
|
||||
overtimePrompt :: C.Update C.CursorMode
|
||||
overtimePrompt = do
|
||||
C.drawString "Did the game go into overtime? (Y/N)"
|
||||
return C.CursorInvisible
|
||||
|
|
Loading…
Reference in New Issue
Block a user