diff --git a/src/Mtlstats/Events.hs b/src/Mtlstats/Events.hs index 3c591e9..6dfd6a8 100644 --- a/src/Mtlstats/Events.hs +++ b/src/Mtlstats/Events.hs @@ -24,6 +24,7 @@ along with this program. If not, see . 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 diff --git a/src/Mtlstats/UI.hs b/src/Mtlstats/UI.hs index 95940f2..160ca5d 100644 --- a/src/Mtlstats/UI.hs +++ b/src/Mtlstats/UI.hs @@ -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