implemented gameStateL

This commit is contained in:
Jonathan Lamothe 2019-08-28 01:04:03 -04:00
parent e36df4348a
commit d7dd682532
2 changed files with 22 additions and 0 deletions

View File

@ -41,6 +41,7 @@ module Mtlstats.Types (
progMode,
inputBuffer,
-- ** ProgMode Lenses
gameStateL,
gameTypeL,
otherTeamL,
homeScoreL,
@ -383,6 +384,13 @@ makeLenses ''Goalie
makeLenses ''GoalieStats
makeLenses ''GameStats
gameStateL :: Lens' ProgMode GameState
gameStateL = lens
(\case
NewGame gs -> gs
_ -> newGameState)
(\_ gs -> NewGame gs)
gameTypeL :: Lens' ProgMode (Maybe GameType)
gameTypeL = lens
(\case

View File

@ -41,6 +41,7 @@ spec = describe "Mtlstats.Types" $ do
gameStatsSpec
databaseSpec
pPointsSpec
gameStateLSpec
gameTypeLSpec
otherTeamLSpec
homeScoreLSpec
@ -80,6 +81,19 @@ pPointsSpec = describe "pPoints" $ mapM_
, ( 2, 3, 5 )
]
gameStateLSpec :: Spec
gameStateLSpec = describe "gameStateL" $ lensSpec gameStateL
-- getters
[ ( MainMenu, newGameState )
, ( NewGame $ gs HomeGame, gs HomeGame )
]
-- setters
[ ( MainMenu, gs HomeGame )
, ( NewGame $ gs HomeGame, gs AwayGame )
, ( NewGame $ gs HomeGame, newGameState )
]
where gs t = newGameState & gameType ?~ t
gameTypeLSpec :: Spec
gameTypeLSpec = describe "gameTypeL" $ lensSpec gameTypeL
[ ( MainMenu, Nothing )