Merge pull request #61 from mtlstats/active-col
Added active field to players/goalies
This commit is contained in:
commit
fcfbcea72f
@ -1,5 +1,8 @@
|
|||||||
# Changelog for mtlstats
|
# Changelog for mtlstats
|
||||||
|
|
||||||
|
## current
|
||||||
|
- Added active flag to players/goalies
|
||||||
|
|
||||||
## 0.10.0
|
## 0.10.0
|
||||||
- Don't show player number zero in reports
|
- Don't show player number zero in reports
|
||||||
- Fixed player/goalie name capitalisation on edit
|
- Fixed player/goalie name capitalisation on edit
|
||||||
|
@ -51,8 +51,12 @@ goalieDetails g = let
|
|||||||
goalieName :: Goalie -> String
|
goalieName :: Goalie -> String
|
||||||
goalieName g = let
|
goalieName g = let
|
||||||
|
|
||||||
|
prefix = if g^.gActive
|
||||||
|
then ""
|
||||||
|
else "*"
|
||||||
|
|
||||||
suffix = if g^.gRookie
|
suffix = if g^.gRookie
|
||||||
then "*"
|
then "*"
|
||||||
else ""
|
else ""
|
||||||
|
|
||||||
in g^.gName ++ suffix
|
in prefix ++ g^.gName ++ suffix
|
||||||
|
@ -49,8 +49,12 @@ playerDetails p = unlines $ top ++ [""] ++ table
|
|||||||
playerName :: Player -> String
|
playerName :: Player -> String
|
||||||
playerName p = let
|
playerName p = let
|
||||||
|
|
||||||
|
prefix = if p^.pActive
|
||||||
|
then ""
|
||||||
|
else "*"
|
||||||
|
|
||||||
suffix = if p^.pRookie
|
suffix = if p^.pRookie
|
||||||
then "*"
|
then "*"
|
||||||
else ""
|
else ""
|
||||||
|
|
||||||
in p^.pName ++ suffix
|
in prefix ++ p^.pName ++ suffix
|
||||||
|
@ -40,15 +40,17 @@ editGoalieMenu = Menu "*** EDIT GOALTENDER ***" () $ map
|
|||||||
-- key, label, value
|
-- key, label, value
|
||||||
[ ( '1', "Edit number", set EGNumber )
|
[ ( '1', "Edit number", set EGNumber )
|
||||||
, ( '2', "Edit name", set EGName )
|
, ( '2', "Edit name", set EGName )
|
||||||
, ( '3', "Toggle rookie flag", toggle )
|
, ( '3', "Toggle rookie flag", toggleRookie )
|
||||||
, ( '4', "Edit YTD stats", set EGYtd )
|
, ( '4', "Toggle active flag", toggleActive )
|
||||||
, ( '5', "Edit Lifetime stats", set EGLifetime )
|
, ( '5', "Edit YTD stats", set EGYtd )
|
||||||
|
, ( '6', "Edit Lifetime stats", set EGLifetime )
|
||||||
, ( 'R', "Return to Edit Menu", edit )
|
, ( 'R', "Return to Edit Menu", edit )
|
||||||
]
|
]
|
||||||
|
|
||||||
where
|
where
|
||||||
set mode = progMode.editGoalieStateL.egsMode .~ mode
|
set mode = progMode.editGoalieStateL.egsMode .~ mode
|
||||||
toggle = editSelectedGoalie (gRookie %~ not)
|
toggleRookie = editSelectedGoalie (gRookie %~ not)
|
||||||
|
toggleActive = editSelectedGoalie (gActive %~ not)
|
||||||
|
|
||||||
-- | The 'Goalie' YTD edit menu
|
-- | The 'Goalie' YTD edit menu
|
||||||
editGoalieYtdMenu :: Menu ()
|
editGoalieYtdMenu :: Menu ()
|
||||||
|
@ -41,15 +41,17 @@ editPlayerMenu = Menu "*** EDIT PLAYER ***" () $ map
|
|||||||
[ ( '1', "Edit number", set EPNumber )
|
[ ( '1', "Edit number", set EPNumber )
|
||||||
, ( '2', "Edit name", set EPName )
|
, ( '2', "Edit name", set EPName )
|
||||||
, ( '3', "Edit position", set EPPosition )
|
, ( '3', "Edit position", set EPPosition )
|
||||||
, ( '4', "Toggle rookie flag", toggle )
|
, ( '4', "Toggle rookie flag", toggleRookie )
|
||||||
, ( '5', "Edit YTD stats", set EPYtd )
|
, ( '5', "Toggle active flag", toggleActive )
|
||||||
, ( '6', "Edit lifetime stats", set EPLifetime )
|
, ( '6', "Edit YTD stats", set EPYtd )
|
||||||
|
, ( '7', "Edit lifetime stats", set EPLifetime )
|
||||||
, ( 'R', "Return to Edit Menu", edit )
|
, ( 'R', "Return to Edit Menu", edit )
|
||||||
]
|
]
|
||||||
|
|
||||||
where
|
where
|
||||||
set mode = progMode.editPlayerStateL.epsMode .~ mode
|
set mode = progMode.editPlayerStateL.epsMode .~ mode
|
||||||
toggle = editSelectedPlayer $ pRookie %~ not
|
toggleRookie = editSelectedPlayer $ pRookie %~ not
|
||||||
|
toggleActive = editSelectedPlayer $ pActive %~ not
|
||||||
|
|
||||||
-- | The 'Player' YTD stats edit menu
|
-- | The 'Player' YTD stats edit menu
|
||||||
editPlayerYtdMenu :: Menu ()
|
editPlayerYtdMenu :: Menu ()
|
||||||
|
@ -107,6 +107,7 @@ module Mtlstats.Types (
|
|||||||
pName,
|
pName,
|
||||||
pPosition,
|
pPosition,
|
||||||
pRookie,
|
pRookie,
|
||||||
|
pActive,
|
||||||
pYtd,
|
pYtd,
|
||||||
pLifetime,
|
pLifetime,
|
||||||
-- ** PlayerStats Lenses
|
-- ** PlayerStats Lenses
|
||||||
@ -117,6 +118,7 @@ module Mtlstats.Types (
|
|||||||
gNumber,
|
gNumber,
|
||||||
gName,
|
gName,
|
||||||
gRookie,
|
gRookie,
|
||||||
|
gActive,
|
||||||
gYtd,
|
gYtd,
|
||||||
gLifetime,
|
gLifetime,
|
||||||
-- ** GoalieStats Lenses
|
-- ** GoalieStats Lenses
|
||||||
@ -411,6 +413,8 @@ data Player = Player
|
|||||||
-- ^ The player's position
|
-- ^ The player's position
|
||||||
, _pRookie :: Bool
|
, _pRookie :: Bool
|
||||||
-- ^ Indicates that the player is a rookie
|
-- ^ Indicates that the player is a rookie
|
||||||
|
, _pActive :: Bool
|
||||||
|
-- ^ Indicates that the player is active
|
||||||
, _pYtd :: PlayerStats
|
, _pYtd :: PlayerStats
|
||||||
-- ^ The Player's year-to-date stats
|
-- ^ The Player's year-to-date stats
|
||||||
, _pLifetime :: PlayerStats
|
, _pLifetime :: PlayerStats
|
||||||
@ -435,6 +439,8 @@ data Goalie = Goalie
|
|||||||
-- ^ The goalie's name
|
-- ^ The goalie's name
|
||||||
, _gRookie :: Bool
|
, _gRookie :: Bool
|
||||||
-- ^ Indicates that the goalie is a rookie
|
-- ^ Indicates that the goalie is a rookie
|
||||||
|
, _gActive :: Bool
|
||||||
|
-- ^ Indicates that the goalie is active
|
||||||
, _gYtd :: GoalieStats
|
, _gYtd :: GoalieStats
|
||||||
-- ^ The goalie's year-to-date stats
|
-- ^ The goalie's year-to-date stats
|
||||||
, _gLifetime :: GoalieStats
|
, _gLifetime :: GoalieStats
|
||||||
@ -555,23 +561,26 @@ instance FromJSON Player where
|
|||||||
<*> v .: "name"
|
<*> v .: "name"
|
||||||
<*> v .: "position"
|
<*> v .: "position"
|
||||||
<*> v .:? "rookie" .!= False
|
<*> v .:? "rookie" .!= False
|
||||||
|
<*> v .:? "active" .!= True
|
||||||
<*> v .:? "ytd" .!= newPlayerStats
|
<*> v .:? "ytd" .!= newPlayerStats
|
||||||
<*> v .:? "lifetime" .!= newPlayerStats
|
<*> v .:? "lifetime" .!= newPlayerStats
|
||||||
|
|
||||||
instance ToJSON Player where
|
instance ToJSON Player where
|
||||||
toJSON (Player num name pos rk ytd lt) = object
|
toJSON (Player num name pos rk act ytd lt) = object
|
||||||
[ "number" .= num
|
[ "number" .= num
|
||||||
, "name" .= name
|
, "name" .= name
|
||||||
, "position" .= pos
|
, "position" .= pos
|
||||||
, "rookie" .= rk
|
, "rookie" .= rk
|
||||||
|
, "active" .= act
|
||||||
, "ytd" .= ytd
|
, "ytd" .= ytd
|
||||||
, "lifetime" .= lt
|
, "lifetime" .= lt
|
||||||
]
|
]
|
||||||
toEncoding (Player num name pos rk ytd lt) = pairs $
|
toEncoding (Player num name pos rk act ytd lt) = pairs $
|
||||||
"number" .= num <>
|
"number" .= num <>
|
||||||
"name" .= name <>
|
"name" .= name <>
|
||||||
"position" .= pos <>
|
"position" .= pos <>
|
||||||
"rookie" .= rk <>
|
"rookie" .= rk <>
|
||||||
|
"active" .= act <>
|
||||||
"ytd" .= ytd <>
|
"ytd" .= ytd <>
|
||||||
"lifetime" .= lt
|
"lifetime" .= lt
|
||||||
|
|
||||||
@ -597,21 +606,24 @@ instance FromJSON Goalie where
|
|||||||
<$> v .: "number"
|
<$> v .: "number"
|
||||||
<*> v .: "name"
|
<*> v .: "name"
|
||||||
<*> v .:? "rookie" .!= False
|
<*> v .:? "rookie" .!= False
|
||||||
|
<*> v .:? "active" .!= True
|
||||||
<*> v .:? "ytd" .!= newGoalieStats
|
<*> v .:? "ytd" .!= newGoalieStats
|
||||||
<*> v .:? "lifetime" .!= newGoalieStats
|
<*> v .:? "lifetime" .!= newGoalieStats
|
||||||
|
|
||||||
instance ToJSON Goalie where
|
instance ToJSON Goalie where
|
||||||
toJSON (Goalie num name rk ytd lt) = object
|
toJSON (Goalie num name rk act ytd lt) = object
|
||||||
[ "number" .= num
|
[ "number" .= num
|
||||||
, "name" .= name
|
, "name" .= name
|
||||||
, "ytd" .= ytd
|
, "ytd" .= ytd
|
||||||
, "rookie" .= rk
|
, "rookie" .= rk
|
||||||
|
, "active" .= act
|
||||||
, "lifetime" .= lt
|
, "lifetime" .= lt
|
||||||
]
|
]
|
||||||
toEncoding (Goalie num name rk ytd lt) = pairs $
|
toEncoding (Goalie num name rk act ytd lt) = pairs $
|
||||||
"number" .= num <>
|
"number" .= num <>
|
||||||
"name" .= name <>
|
"name" .= name <>
|
||||||
"rookie" .= rk <>
|
"rookie" .= rk <>
|
||||||
|
"active" .= act <>
|
||||||
"ytd" .= ytd <>
|
"ytd" .= ytd <>
|
||||||
"lifetime" .= lt
|
"lifetime" .= lt
|
||||||
|
|
||||||
@ -795,6 +807,7 @@ newPlayer num name pos = Player
|
|||||||
, _pName = name
|
, _pName = name
|
||||||
, _pPosition = pos
|
, _pPosition = pos
|
||||||
, _pRookie = True
|
, _pRookie = True
|
||||||
|
, _pActive = True
|
||||||
, _pYtd = newPlayerStats
|
, _pYtd = newPlayerStats
|
||||||
, _pLifetime = newPlayerStats
|
, _pLifetime = newPlayerStats
|
||||||
}
|
}
|
||||||
@ -818,6 +831,7 @@ newGoalie num name = Goalie
|
|||||||
{ _gNumber = num
|
{ _gNumber = num
|
||||||
, _gName = name
|
, _gName = name
|
||||||
, _gRookie = True
|
, _gRookie = True
|
||||||
|
, _gActive = True
|
||||||
, _gYtd = newGoalieStats
|
, _gYtd = newGoalieStats
|
||||||
, _gLifetime = newGoalieStats
|
, _gLifetime = newGoalieStats
|
||||||
}
|
}
|
||||||
|
@ -76,10 +76,16 @@ goalieNameSpec = describe "goalieName" $ mapM_
|
|||||||
it ("should be " ++ expected) $
|
it ("should be " ++ expected) $
|
||||||
goalieName g `shouldBe` expected)
|
goalieName g `shouldBe` expected)
|
||||||
|
|
||||||
-- label, goalie, expected
|
-- label, goalie, expected
|
||||||
[ ( "rookie", goalie True, "foo*" )
|
[ ( "rookie", rookie, "foo*" )
|
||||||
, ( "non-rookie", goalie False, "foo" )
|
, ( "non-rookie", active, "foo" )
|
||||||
|
, ( "retired", retired, "*foo" )
|
||||||
]
|
]
|
||||||
|
|
||||||
where
|
where
|
||||||
goalie r = newGoalie 1 "foo" & gRookie .~ r
|
rookie = goalie True True
|
||||||
|
active = goalie False True
|
||||||
|
retired = goalie False False
|
||||||
|
goalie r a = newGoalie 1 "foo"
|
||||||
|
& gRookie .~ r
|
||||||
|
& gActive .~ a
|
||||||
|
@ -71,9 +71,13 @@ playerNameSpec = describe "playerName" $ mapM_
|
|||||||
-- label, player, expected
|
-- label, player, expected
|
||||||
[ ( "rookie", rookie, "foo*" )
|
[ ( "rookie", rookie, "foo*" )
|
||||||
, ( "non-rookie", nonRookie, "foo" )
|
, ( "non-rookie", nonRookie, "foo" )
|
||||||
|
, ( "retired", retired, "*foo" )
|
||||||
]
|
]
|
||||||
|
|
||||||
where
|
where
|
||||||
rookie = player True
|
rookie = player True True
|
||||||
nonRookie = player False
|
nonRookie = player False True
|
||||||
player r = newPlayer 1 "foo" "centre" & pRookie .~ r
|
retired = player False False
|
||||||
|
player r a = newPlayer 1 "foo" "centre"
|
||||||
|
& pRookie .~ r
|
||||||
|
& pActive .~ a
|
||||||
|
@ -281,6 +281,7 @@ playerJSON = Object $ HM.fromList
|
|||||||
, ( "name", toJSON ("Joe" :: String) )
|
, ( "name", toJSON ("Joe" :: String) )
|
||||||
, ( "position", toJSON ("centre" :: String) )
|
, ( "position", toJSON ("centre" :: String) )
|
||||||
, ( "rookie", toJSON False )
|
, ( "rookie", toJSON False )
|
||||||
|
, ( "active", toJSON True )
|
||||||
, ( "ytd", playerStatsJSON 1 )
|
, ( "ytd", playerStatsJSON 1 )
|
||||||
, ( "lifetime", playerStatsJSON 2 )
|
, ( "lifetime", playerStatsJSON 2 )
|
||||||
]
|
]
|
||||||
@ -309,6 +310,7 @@ goalieJSON = Object $ HM.fromList
|
|||||||
[ ( "number", toJSON (1 :: Int) )
|
[ ( "number", toJSON (1 :: Int) )
|
||||||
, ( "name", toJSON ("Joe" :: String ) )
|
, ( "name", toJSON ("Joe" :: String ) )
|
||||||
, ( "rookie", toJSON False )
|
, ( "rookie", toJSON False )
|
||||||
|
, ( "active", toJSON True )
|
||||||
, ( "ytd", goalieStatsJSON 1 )
|
, ( "ytd", goalieStatsJSON 1 )
|
||||||
, ( "lifetime", goalieStatsJSON 2 )
|
, ( "lifetime", goalieStatsJSON 2 )
|
||||||
]
|
]
|
||||||
@ -848,6 +850,7 @@ makePlayer = Player
|
|||||||
<*> makeName
|
<*> makeName
|
||||||
<*> makeName
|
<*> makeName
|
||||||
<*> makeBool
|
<*> makeBool
|
||||||
|
<*> makeBool
|
||||||
<*> makePlayerStats
|
<*> makePlayerStats
|
||||||
<*> makePlayerStats
|
<*> makePlayerStats
|
||||||
|
|
||||||
@ -857,6 +860,7 @@ makeGoalie = Goalie
|
|||||||
<$> makeNum
|
<$> makeNum
|
||||||
<*> makeName
|
<*> makeName
|
||||||
<*> makeBool
|
<*> makeBool
|
||||||
|
<*> makeBool
|
||||||
<*> makeGoalieStats
|
<*> makeGoalieStats
|
||||||
<*> makeGoalieStats
|
<*> makeGoalieStats
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user