mtlstats/src/Mtlstats/Control/GoalieInput.hs

62 lines
1.8 KiB
Haskell
Raw Normal View History

2019-10-29 02:00:14 -04:00
{- |
mtlstats
Copyright (C) 2019 Rhéal Lamothe
<rheal.lamothe@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-}
module Mtlstats.Control.GoalieInput (goalieInput) where
2019-10-30 23:41:55 -04:00
import Data.Maybe (fromMaybe)
2019-10-29 02:40:17 -04:00
import Lens.Micro ((^.))
2019-10-30 23:41:55 -04:00
import qualified UI.NCurses as C
2019-10-29 02:40:17 -04:00
2019-10-30 23:41:55 -04:00
import Mtlstats.Format
import Mtlstats.Prompt
import Mtlstats.Prompt.GoalieInput
2019-10-29 02:00:14 -04:00
import Mtlstats.Types
2019-10-30 23:41:55 -04:00
import Mtlstats.Util
2019-10-29 02:00:14 -04:00
-- | The dispatcher for handling goalie input
goalieInput :: GameState -> Controller
2019-10-29 02:40:17 -04:00
goalieInput gs
| gs^.gameGoaliesRecorded = selectGameGoalieC
| null $ gs^.gameSelectedGoalie = selectGoalieC
| null $ gs^.gameGoalieMinsPlayed = minsPlayedC
| otherwise = goalsAllowedC
2019-10-29 02:40:17 -04:00
selectGoalieC :: Controller
selectGoalieC = promptController selectGameGoaliePrompt
2019-10-29 02:40:17 -04:00
minsPlayedC :: Controller
minsPlayedC = promptControllerWith header goalieMinsPlayedPrompt
2019-10-29 02:40:17 -04:00
goalsAllowedC :: Controller
goalsAllowedC = promptControllerWith header goalsAllowedPrompt
2019-10-30 23:41:55 -04:00
selectGameGoalieC :: Controller
selectGameGoalieC = undefined
header :: ProgState -> C.Update ()
header s = C.drawString $ unlines
2019-10-30 23:41:55 -04:00
[ "*** GAME " ++ padNum 2 (s^.database.dbGames) ++ " ***"
, fromMaybe "" $ do
n <- s^.progMode.gameStateL.gameSelectedGoalie
g <- nth n $ s^.database.dbGoalies
Just $ goalieSummary g
]