renamed pPoints to psPoints

This commit is contained in:
Jonathan Lamothe 2019-10-09 00:35:35 -04:00
parent 0b249bcdae
commit a9c036f876
3 changed files with 26 additions and 26 deletions

View File

@ -117,7 +117,7 @@ gameStatsReport width s = unlines $ fromMaybe [] $ do
++ left nameWidth (p^.pName)
++ right 3 (show $ stats^.psGoals)
++ right 6 (show $ stats^.psAssists)
++ right 6 (show $ pPoints stats)
++ right 6 (show $ psPoints stats)
++ right 6 (show $ stats^.psPMin))
pStats ++
[ centre width
@ -129,7 +129,7 @@ gameStatsReport width s = unlines $ fromMaybe [] $ do
$ replicate (4 + nameWidth) ' '
++ right 3 (show $ tStats^.psGoals)
++ right 6 (show $ tStats^.psAssists)
++ right 6 (show $ pPoints tStats)
++ right 6 (show $ psPoints tStats)
++ right 6 (show $ tStats^.psPMin)
)
]

View File

@ -126,12 +126,12 @@ module Mtlstats.Types (
gmsPoints,
addGameStats,
-- ** Player Helpers
pPoints,
playerSearch,
playerSearchExact,
modifyPlayer,
playerSummary,
-- ** PlayerStats Helpers
psPoints,
addPlayerStats
) where
@ -677,10 +677,6 @@ addGameStats s1 s2 = GameStats
, _gmsGoalsAgainst = s1^.gmsGoalsAgainst + s2^.gmsGoalsAgainst
}
-- | Calculates a player's points
pPoints :: PlayerStats -> Int
pPoints s = s^.psGoals + s^.psAssists
-- | Searches through a list of players
playerSearch
:: String
@ -728,6 +724,10 @@ playerSummary :: Player -> String
playerSummary p =
p^.pName ++ " (" ++ show (p^.pNumber) ++ ") " ++ p^.pPosition
-- | Calculates a player's points
psPoints :: PlayerStats -> Int
psPoints s = s^.psGoals + s^.psAssists
-- | Adds two 'PlayerStats' together
addPlayerStats :: PlayerStats -> PlayerStats -> PlayerStats
addPlayerStats s1 s2 = newPlayerStats

View File

@ -54,11 +54,11 @@ spec = describe "Mtlstats.Types" $ do
gmsGamesSpec
gmsPointsSpec
addGameStatsSpec
pPointsSpec
playerSearchSpec
playerSearchExactSpec
modifyPlayerSpec
playerSummarySpec
psPointsSpec
addPlayerStatsSpec
Menu.spec
@ -510,24 +510,6 @@ addGameStatsSpec = describe "addGameStats" $
in addGameStats s1 s2 `shouldBe` expected
pPointsSpec :: Spec
pPointsSpec = describe "pPoints" $ mapM_
(\(goals, assists, points) -> let
desc = "goals: " ++ show goals ++
", assists: " ++ show assists
stats = newPlayerStats &
psGoals .~ goals &
psAssists .~ assists
in context desc $
it ("should be " ++ show points) $
pPoints stats `shouldBe` points)
-- goals, assists, points
[ ( 0, 0, 0 )
, ( 1, 0, 1 )
, ( 0, 1, 1 )
, ( 2, 3, 5 )
]
playerSearchSpec :: Spec
playerSearchSpec = describe "playerSearch" $ mapM_
(\(sStr, expected) -> context sStr $
@ -585,6 +567,24 @@ playerSummarySpec = describe "playerSummary" $
it "should be \"Joe (2) center\"" $
playerSummary joe `shouldBe` "Joe (2) center"
psPointsSpec :: Spec
psPointsSpec = describe "psPoints" $ mapM_
(\(goals, assists, points) -> let
desc = "goals: " ++ show goals ++
", assists: " ++ show assists
stats = newPlayerStats &
psGoals .~ goals &
psAssists .~ assists
in context desc $
it ("should be " ++ show points) $
psPoints stats `shouldBe` points)
-- goals, assists, points
[ ( 0, 0, 0 )
, ( 1, 0, 1 )
, ( 0, 1, 1 )
, ( 2, 3, 5 )
]
addPlayerStatsSpec :: Spec
addPlayerStatsSpec = describe "addPlayerStats" $ do
let