added _otherTeam with its associated lenses

This commit is contained in:
Jonathan Lamothe
2019-08-25 09:23:59 -04:00
parent 2a2189c7d1
commit 0f9f76ce4e
2 changed files with 41 additions and 0 deletions

View File

@@ -41,10 +41,12 @@ module Mtlstats.Types (
inputBuffer,
-- ** GameState Lenses
gameType,
otherTeam,
homeScore,
awayScore,
-- ** ProgMode Lenses
gameTypeL,
otherTeamL,
homeScoreL,
awayScoreL,
-- ** Database Lenses
@@ -123,6 +125,8 @@ data ProgState = ProgState
data GameState = GameState
{ _gameType :: Maybe GameType
-- ^ The type of game (home/away)
, _otherTeam :: String
-- ^ The name of the other team
, _homeScore :: Maybe Int
-- ^ The home team's score
, _awayScore :: Maybe Int
@@ -341,6 +345,15 @@ gameTypeL = lens
NewGame gs -> NewGame $ gs & gameType .~ gt
_ -> NewGame $ newGameState & gameType .~ gt)
otherTeamL :: Lens' ProgMode String
otherTeamL = lens
(\case
NewGame gs -> gs ^. otherTeam
_ -> "")
(\m ot -> case m of
NewGame gs -> NewGame $ gs & otherTeam .~ ot
_ -> NewGame $ newGameState & otherTeam .~ ot)
homeScoreL :: Lens' ProgMode (Maybe Int)
homeScoreL = lens
(\case
@@ -371,6 +384,7 @@ newProgState = ProgState
newGameState :: GameState
newGameState = GameState
{ _gameType = Nothing
, _otherTeam = ""
, _homeScore = Nothing
, _awayScore = Nothing
}