make gameWon and gameTied return Maybe Bool instead of Bool

This commit is contained in:
Jonathan Lamothe
2019-08-30 00:43:09 -04:00
parent 45427a050e
commit 3fe2ff10f6
3 changed files with 27 additions and 29 deletions

View File

@@ -30,6 +30,7 @@ module Mtlstats.Actions
, overtimeCheck
) where
import Data.Maybe (fromMaybe)
import Lens.Micro (over, (^.), (&), (.~), (?~), (%~))
import Mtlstats.Types
@@ -63,10 +64,10 @@ removeChar = inputBuffer %~ \case
-- | Determines whether or not to perform a check for overtime
overtimeCheck :: ProgState -> ProgState
overtimeCheck s
| gameTied (s^.progMode.gameStateL) =
| fromMaybe False $ gameTied $ s^.progMode.gameStateL =
s & progMode.gameStateL
%~ (homeScore .~ Nothing)
. (awayScore .~ Nothing)
| gameWon (s^.progMode.gameStateL) =
| fromMaybe False $ gameWon $ s^.progMode.gameStateL =
s & progMode.gameStateL.overtimeFlag ?~ False
| otherwise = s