simplified goalsAllowedPrompt
This commit is contained in:
parent
7fd837863b
commit
d708bed77d
|
@ -28,6 +28,7 @@ import qualified Data.Map as M
|
|||
import Data.Maybe (fromMaybe)
|
||||
import Lens.Micro ((^.), (&), (.~), (%~), (+~))
|
||||
|
||||
import Mtlstats.Config
|
||||
import Mtlstats.Types
|
||||
import Mtlstats.Util
|
||||
|
||||
|
@ -56,6 +57,10 @@ recordGoalieStats s = fromMaybe s $ do
|
|||
& gsMinsPlayed +~ mins
|
||||
& gsGoalsAllowed +~ goals
|
||||
|
||||
tryFinish = if mins >= gameLength
|
||||
then finishGoalieEntry
|
||||
else id
|
||||
|
||||
Just $ s
|
||||
& progMode.gameStateL
|
||||
%~ (gameGoalieStats %~ updateMap gid newGoalieStats bumpStats)
|
||||
|
@ -66,3 +71,4 @@ recordGoalieStats s = fromMaybe s $ do
|
|||
%~ modifyNth gid (\goalie -> goalie
|
||||
& gYtd %~ bumpStats
|
||||
& gLifetime %~ bumpStats)
|
||||
& tryFinish
|
||||
|
|
|
@ -53,7 +53,4 @@ goalieMinsPlayedPrompt = numPrompt "Minutes played: " $
|
|||
goalsAllowedPrompt :: Prompt
|
||||
goalsAllowedPrompt = numPrompt "Goals allowed: " $ \n -> do
|
||||
modify (progMode.gameStateL.gameGoalsAllowed ?~ n)
|
||||
mins <- fromMaybe 0 <$> gets (^.progMode.gameStateL.gameGoalieMinsPlayed)
|
||||
when (mins >= gameLength) $
|
||||
modify $ progMode.gameStateL.gameGoaliesRecorded .~ True
|
||||
modify recordGoalieStats
|
||||
|
|
Loading…
Reference in New Issue
Block a user