simplified goalsAllowedPrompt

This commit is contained in:
Jonathan Lamothe 2019-11-04 03:00:02 -05:00
parent 7fd837863b
commit d708bed77d
2 changed files with 6 additions and 3 deletions

View File

@ -28,6 +28,7 @@ import qualified Data.Map as M
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
import Lens.Micro ((^.), (&), (.~), (%~), (+~)) import Lens.Micro ((^.), (&), (.~), (%~), (+~))
import Mtlstats.Config
import Mtlstats.Types import Mtlstats.Types
import Mtlstats.Util import Mtlstats.Util
@ -56,6 +57,10 @@ recordGoalieStats s = fromMaybe s $ do
& gsMinsPlayed +~ mins & gsMinsPlayed +~ mins
& gsGoalsAllowed +~ goals & gsGoalsAllowed +~ goals
tryFinish = if mins >= gameLength
then finishGoalieEntry
else id
Just $ s Just $ s
& progMode.gameStateL & progMode.gameStateL
%~ (gameGoalieStats %~ updateMap gid newGoalieStats bumpStats) %~ (gameGoalieStats %~ updateMap gid newGoalieStats bumpStats)
@ -66,3 +71,4 @@ recordGoalieStats s = fromMaybe s $ do
%~ modifyNth gid (\goalie -> goalie %~ modifyNth gid (\goalie -> goalie
& gYtd %~ bumpStats & gYtd %~ bumpStats
& gLifetime %~ bumpStats) & gLifetime %~ bumpStats)
& tryFinish

View File

@ -53,7 +53,4 @@ goalieMinsPlayedPrompt = numPrompt "Minutes played: " $
goalsAllowedPrompt :: Prompt goalsAllowedPrompt :: Prompt
goalsAllowedPrompt = numPrompt "Goals allowed: " $ \n -> do goalsAllowedPrompt = numPrompt "Goals allowed: " $ \n -> do
modify (progMode.gameStateL.gameGoalsAllowed ?~ n) modify (progMode.gameStateL.gameGoalsAllowed ?~ n)
mins <- fromMaybe 0 <$> gets (^.progMode.gameStateL.gameGoalieMinsPlayed)
when (mins >= gameLength) $
modify $ progMode.gameStateL.gameGoaliesRecorded .~ True
modify recordGoalieStats modify recordGoalieStats