From a66be1a45e8b11867cdeaa18658fb69d7896ec46 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 19 Sep 2019 06:12:02 -0400 Subject: [PATCH] prompt user for players who've scored goals --- src/Mtlstats/Control.hs | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/Mtlstats/Control.hs b/src/Mtlstats/Control.hs index 8dcc9cb..8b00523 100644 --- a/src/Mtlstats/Control.hs +++ b/src/Mtlstats/Control.hs @@ -44,16 +44,17 @@ dispatch s = case s^.progMode of MainMenu -> mainMenuC NewSeason -> newSeasonC NewGame gs - | null $ gs^.gameYear -> gameYearC - | null $ gs^.gameMonth -> gameMonthC - | null $ gs^.gameDay -> gameDayC - | null $ gs^.gameType -> gameTypeC - | null $ gs^.otherTeam -> otherTeamC - | null $ gs^.homeScore -> homeScoreC - | null $ gs^.awayScore -> awayScoreC - | null $ gs^.overtimeFlag -> overtimeFlagC - | not $ gs^.dataVerified -> verifyDataC - | otherwise -> reportC + | null $ gs^.gameYear -> gameYearC + | null $ gs^.gameMonth -> gameMonthC + | null $ gs^.gameDay -> gameDayC + | null $ gs^.gameType -> gameTypeC + | null $ gs^.otherTeam -> otherTeamC + | null $ gs^.homeScore -> homeScoreC + | null $ gs^.awayScore -> awayScoreC + | null $ gs^.overtimeFlag -> overtimeFlagC + | not $ gs^.dataVerified -> verifyDataC + | fromJust (unaccountedPoints gs) -> recordGoalC + | otherwise -> reportC CreatePlayer cps | null $ cps^.cpsNumber -> getPlayerNumC | null $ cps^.cpsName -> getPlayerNameC @@ -181,6 +182,19 @@ verifyDataC = Controller return True } +recordGoalC :: Controller +recordGoalC = Controller + { drawController = \s -> let + game = s^.database.dbGames + goal = succ $ s^.progMode.gameStateL.pointsAccounted + in drawPrompt (recordGoalPrompt game goal) s + , handleController = \e -> do + game <- gets $ view $ database.dbGames + goal <- succ <$> gets (view $ progMode.gameStateL.pointsAccounted) + promptHandler (recordGoalPrompt game goal) e + return True + } + reportC :: Controller reportC = Controller { drawController = \s -> do