diff --git a/src/Mtlstats/Control.hs b/src/Mtlstats/Control.hs index 8b00523..3c4834d 100644 --- a/src/Mtlstats/Control.hs +++ b/src/Mtlstats/Control.hs @@ -53,7 +53,7 @@ dispatch s = case s^.progMode of | null $ gs^.awayScore -> awayScoreC | null $ gs^.overtimeFlag -> overtimeFlagC | not $ gs^.dataVerified -> verifyDataC - | fromJust (unaccountedPoints gs) -> recordGoalC + | fromJust (unaccountedPoints gs) -> goalInput gs | otherwise -> reportC CreatePlayer cps | null $ cps^.cpsNumber -> getPlayerNumC @@ -182,6 +182,11 @@ verifyDataC = Controller return True } +goalInput :: GameState -> Controller +goalInput gs + | null (gs^.goalBy) = recordGoalC + | otherwise = recordAssistC + recordGoalC :: Controller recordGoalC = Controller { drawController = \s -> let @@ -195,6 +200,9 @@ recordGoalC = Controller return True } +recordAssistC :: Controller +recordAssistC = undefined + reportC :: Controller reportC = Controller { drawController = \s -> do diff --git a/src/Mtlstats/Prompt.hs b/src/Mtlstats/Prompt.hs index 04bb138..ee101d2 100644 --- a/src/Mtlstats/Prompt.hs +++ b/src/Mtlstats/Prompt.hs @@ -205,13 +205,14 @@ recordGoalPrompt -- ^ The goal number -> Prompt recordGoalPrompt game goal = selectPlayerPrompt - ("*** GAME " ++ padNum 2 game ++ " ***\n" ++ - "Who scored goal number " ++ show goal ++ "? ") $ - \case + ( "*** GAME " ++ padNum 2 game ++ " ***\n" ++ + "Who scored goal number " ++ show goal ++ "? " + ) $ \case Nothing -> return () - Just n -> modify - $ awardGoal n - . (progMode.gameStateL.pointsAccounted %~ succ) + Just n -> nth n <$> gets (view $ database.dbPlayers) + >>= maybe + (return ()) + (\p -> modify $ progMode.gameStateL.goalBy .~ p^.pName) drawSimplePrompt :: String -> ProgState -> C.Update () drawSimplePrompt pStr s = C.drawString $ pStr ++ s^.inputBuffer