implemented gameStateL
This commit is contained in:
parent
e36df4348a
commit
d7dd682532
|
@ -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
|
||||
|
|
|
@ -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 )
|
||||
|
|
Loading…
Reference in New Issue
Block a user