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, progMode,
inputBuffer, inputBuffer,
-- ** ProgMode Lenses -- ** ProgMode Lenses
gameStateL,
gameTypeL, gameTypeL,
otherTeamL, otherTeamL,
homeScoreL, homeScoreL,
@ -383,6 +384,13 @@ makeLenses ''Goalie
makeLenses ''GoalieStats makeLenses ''GoalieStats
makeLenses ''GameStats makeLenses ''GameStats
gameStateL :: Lens' ProgMode GameState
gameStateL = lens
(\case
NewGame gs -> gs
_ -> newGameState)
(\_ gs -> NewGame gs)
gameTypeL :: Lens' ProgMode (Maybe GameType) gameTypeL :: Lens' ProgMode (Maybe GameType)
gameTypeL = lens gameTypeL = lens
(\case (\case

View File

@ -41,6 +41,7 @@ spec = describe "Mtlstats.Types" $ do
gameStatsSpec gameStatsSpec
databaseSpec databaseSpec
pPointsSpec pPointsSpec
gameStateLSpec
gameTypeLSpec gameTypeLSpec
otherTeamLSpec otherTeamLSpec
homeScoreLSpec homeScoreLSpec
@ -80,6 +81,19 @@ pPointsSpec = describe "pPoints" $ mapM_
, ( 2, 3, 5 ) , ( 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 :: Spec
gameTypeLSpec = describe "gameTypeL" $ lensSpec gameTypeL gameTypeLSpec = describe "gameTypeL" $ lensSpec gameTypeL
[ ( MainMenu, Nothing ) [ ( MainMenu, Nothing )