implemented minsPlayedC

This commit is contained in:
Jonathan Lamothe 2019-10-30 23:41:55 -04:00
parent 1c692a21f0
commit a6395ada9c
2 changed files with 27 additions and 2 deletions

View File

@ -21,10 +21,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
module Mtlstats.Control.GoalieInput (goalieInput) where module Mtlstats.Control.GoalieInput (goalieInput) where
import Data.Maybe (fromMaybe)
import Lens.Micro ((^.)) import Lens.Micro ((^.))
import qualified UI.NCurses as C
import Mtlstats.Format
import Mtlstats.Prompt import Mtlstats.Prompt
import Mtlstats.Types import Mtlstats.Types
import Mtlstats.Util
-- | The dispatcher for handling goalie input -- | The dispatcher for handling goalie input
goalieInput :: GameState -> Controller goalieInput :: GameState -> Controller
@ -42,7 +46,23 @@ selectGoalieC = Controller
} }
minsPlayedC :: Controller minsPlayedC :: Controller
minsPlayedC = undefined minsPlayedC = Controller
{ drawController = \s -> do
C.drawString $ header s
drawPrompt goalieMinsPlayedPrompt s
, handleController = \e -> do
promptHandler goalieMinsPlayedPrompt e
return True
}
goalsAllowedC :: Controller goalsAllowedC :: Controller
goalsAllowedC = undefined goalsAllowedC = undefined
header :: ProgState -> String
header s = unlines
[ "*** GAME " ++ padNum 2 (s^.database.dbGames) ++ " ***"
, fromMaybe "" $ do
n <- s^.progMode.gameStateL.gameSelectedGoalie
g <- nth n $ s^.database.dbGoalies
Just $ goalieSummary g
]

View File

@ -45,7 +45,8 @@ module Mtlstats.Prompt (
assignPMinsPrompt, assignPMinsPrompt,
goalieNumPrompt, goalieNumPrompt,
goalieNamePrompt, goalieNamePrompt,
selectGameGoaliePrompt selectGameGoaliePrompt,
goalieMinsPlayedPrompt
) where ) where
import Control.Monad (when) import Control.Monad (when)
@ -310,5 +311,9 @@ selectGameGoaliePrompt = selectGoaliePrompt "Which goalie played this game: " $
Nothing -> modify $ progMode.gameStateL.goaliesRecorded .~ True Nothing -> modify $ progMode.gameStateL.goaliesRecorded .~ True
Just n -> modify $ progMode.gameStateL.gameSelectedGoalie ?~ n Just n -> modify $ progMode.gameStateL.gameSelectedGoalie ?~ n
-- | Prompts for the number of minutes the goalie has played
goalieMinsPlayedPrompt :: Prompt
goalieMinsPlayedPrompt = undefined
drawSimplePrompt :: String -> ProgState -> C.Update () drawSimplePrompt :: String -> ProgState -> C.Update ()
drawSimplePrompt pStr s = C.drawString $ pStr ++ s^.inputBuffer drawSimplePrompt pStr s = C.drawString $ pStr ++ s^.inputBuffer