implemented goalsAllowedPrompt

This commit is contained in:
Jonathan Lamothe 2019-10-31 01:21:21 -04:00
parent cb0b4f9d0b
commit ff541c2385
3 changed files with 16 additions and 1 deletions

View File

@ -41,6 +41,7 @@ module Mtlstats.Actions
, awardAssist
, resetGoalData
, assignPMins
, recordGoalieStats
, backHome
, scrollUp
, scrollDown
@ -269,6 +270,10 @@ assignPMins mins s = fromMaybe s $ do
)
. (selectedPlayer .~ Nothing)
-- | Records the goalie's game stats
recordGoalieStats :: ProgState -> ProgState
recordGoalieStats = undefined
-- | Resets the program state back to the main menu
backHome :: ProgState -> ProgState
backHome

View File

@ -40,3 +40,7 @@ dbFname = "database.json"
-- | The maximum number of assists
maxAssists :: Int
maxAssists = 2
-- | The length of a typical game (in minutes)
gameLength :: Int
gameLength = 60

View File

@ -55,6 +55,7 @@ import Control.Monad.Extra (whenJust)
import Control.Monad.Trans.State (gets, modify)
import Data.Char (isDigit, toUpper)
import Data.Foldable (forM_)
import Data.Maybe (fromMaybe)
import Lens.Micro ((^.), (&), (.~), (?~), (%~))
import Lens.Micro.Extras (view)
import Text.Read (readMaybe)
@ -319,7 +320,12 @@ goalieMinsPlayedPrompt = numPrompt "Minutes played: " $
-- | Prompts for the number of goals the goalie allowed
goalsAllowedPrompt :: Prompt
goalsAllowedPrompt = undefined
goalsAllowedPrompt = numPrompt "Goals allowed: " $ \n -> do
modify (progMode.gameStateL.goalsAllowed ?~ n)
mins <- fromMaybe 0 <$> gets (^.progMode.gameStateL.goalieMinsPlayed)
when (mins >= gameLength) $
modify $ progMode.gameStateL.goaliesRecorded .~ True
modify recordGoalieStats
drawSimplePrompt :: String -> ProgState -> C.Update ()
drawSimplePrompt pStr s = C.drawString $ pStr ++ s^.inputBuffer