renamed pPoints to psPoints
This commit is contained in:
parent
0b249bcdae
commit
a9c036f876
|
@ -117,7 +117,7 @@ gameStatsReport width s = unlines $ fromMaybe [] $ do
|
||||||
++ left nameWidth (p^.pName)
|
++ left nameWidth (p^.pName)
|
||||||
++ right 3 (show $ stats^.psGoals)
|
++ right 3 (show $ stats^.psGoals)
|
||||||
++ right 6 (show $ stats^.psAssists)
|
++ right 6 (show $ stats^.psAssists)
|
||||||
++ right 6 (show $ pPoints stats)
|
++ right 6 (show $ psPoints stats)
|
||||||
++ right 6 (show $ stats^.psPMin))
|
++ right 6 (show $ stats^.psPMin))
|
||||||
pStats ++
|
pStats ++
|
||||||
[ centre width
|
[ centre width
|
||||||
|
@ -129,7 +129,7 @@ gameStatsReport width s = unlines $ fromMaybe [] $ do
|
||||||
$ replicate (4 + nameWidth) ' '
|
$ replicate (4 + nameWidth) ' '
|
||||||
++ right 3 (show $ tStats^.psGoals)
|
++ right 3 (show $ tStats^.psGoals)
|
||||||
++ right 6 (show $ tStats^.psAssists)
|
++ right 6 (show $ tStats^.psAssists)
|
||||||
++ right 6 (show $ pPoints tStats)
|
++ right 6 (show $ psPoints tStats)
|
||||||
++ right 6 (show $ tStats^.psPMin)
|
++ right 6 (show $ tStats^.psPMin)
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
|
@ -126,12 +126,12 @@ module Mtlstats.Types (
|
||||||
gmsPoints,
|
gmsPoints,
|
||||||
addGameStats,
|
addGameStats,
|
||||||
-- ** Player Helpers
|
-- ** Player Helpers
|
||||||
pPoints,
|
|
||||||
playerSearch,
|
playerSearch,
|
||||||
playerSearchExact,
|
playerSearchExact,
|
||||||
modifyPlayer,
|
modifyPlayer,
|
||||||
playerSummary,
|
playerSummary,
|
||||||
-- ** PlayerStats Helpers
|
-- ** PlayerStats Helpers
|
||||||
|
psPoints,
|
||||||
addPlayerStats
|
addPlayerStats
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
@ -677,10 +677,6 @@ addGameStats s1 s2 = GameStats
|
||||||
, _gmsGoalsAgainst = s1^.gmsGoalsAgainst + s2^.gmsGoalsAgainst
|
, _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
|
-- | Searches through a list of players
|
||||||
playerSearch
|
playerSearch
|
||||||
:: String
|
:: String
|
||||||
|
@ -728,6 +724,10 @@ playerSummary :: Player -> String
|
||||||
playerSummary p =
|
playerSummary p =
|
||||||
p^.pName ++ " (" ++ show (p^.pNumber) ++ ") " ++ p^.pPosition
|
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
|
-- | Adds two 'PlayerStats' together
|
||||||
addPlayerStats :: PlayerStats -> PlayerStats -> PlayerStats
|
addPlayerStats :: PlayerStats -> PlayerStats -> PlayerStats
|
||||||
addPlayerStats s1 s2 = newPlayerStats
|
addPlayerStats s1 s2 = newPlayerStats
|
||||||
|
|
|
@ -54,11 +54,11 @@ spec = describe "Mtlstats.Types" $ do
|
||||||
gmsGamesSpec
|
gmsGamesSpec
|
||||||
gmsPointsSpec
|
gmsPointsSpec
|
||||||
addGameStatsSpec
|
addGameStatsSpec
|
||||||
pPointsSpec
|
|
||||||
playerSearchSpec
|
playerSearchSpec
|
||||||
playerSearchExactSpec
|
playerSearchExactSpec
|
||||||
modifyPlayerSpec
|
modifyPlayerSpec
|
||||||
playerSummarySpec
|
playerSummarySpec
|
||||||
|
psPointsSpec
|
||||||
addPlayerStatsSpec
|
addPlayerStatsSpec
|
||||||
Menu.spec
|
Menu.spec
|
||||||
|
|
||||||
|
@ -510,24 +510,6 @@ addGameStatsSpec = describe "addGameStats" $
|
||||||
|
|
||||||
in addGameStats s1 s2 `shouldBe` expected
|
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 :: Spec
|
||||||
playerSearchSpec = describe "playerSearch" $ mapM_
|
playerSearchSpec = describe "playerSearch" $ mapM_
|
||||||
(\(sStr, expected) -> context sStr $
|
(\(sStr, expected) -> context sStr $
|
||||||
|
@ -585,6 +567,24 @@ playerSummarySpec = describe "playerSummary" $
|
||||||
it "should be \"Joe (2) center\"" $
|
it "should be \"Joe (2) center\"" $
|
||||||
playerSummary joe `shouldBe` "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 :: Spec
|
||||||
addPlayerStatsSpec = describe "addPlayerStats" $ do
|
addPlayerStatsSpec = describe "addPlayerStats" $ do
|
||||||
let
|
let
|
||||||
|
|
Loading…
Reference in New Issue
Block a user