mtlstats/src/Mtlstats/Control/NewGame/GoalieInput.hs

63 lines
1.9 KiB
Haskell
Raw Normal View History

2019-10-29 02:00:14 -04:00
{- |
mtlstats
Copyright (C) 1984, 1985, 2019, 2020, 2021 Rhéal Lamothe
2019-10-29 02:00:14 -04:00
<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.NewGame.GoalieInput (goalieInputC) where
2019-10-29 02:00:14 -04:00
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
2019-11-04 04:12:20 -05:00
import Mtlstats.Menu
import Mtlstats.Prompt
import Mtlstats.Prompt.NewGame.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
2019-11-23 01:13:17 -05:00
goalieInputC :: GameState -> Controller
goalieInputC 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
2019-11-23 01:13:17 -05:00
selectGameGoalieC :: Controller
selectGameGoalieC = menuStateController gameGoalieMenu
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
]