diff --git a/src/Mtlstats/Report.hs b/src/Mtlstats/Report.hs index 9c4212e..17db30a 100644 --- a/src/Mtlstats/Report.hs +++ b/src/Mtlstats/Report.hs @@ -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) ) ] diff --git a/src/Mtlstats/Types.hs b/src/Mtlstats/Types.hs index 65c9e1d..152c728 100644 --- a/src/Mtlstats/Types.hs +++ b/src/Mtlstats/Types.hs @@ -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 diff --git a/test/TypesSpec.hs b/test/TypesSpec.hs index 2fa4d83..c9f7257 100644 --- a/test/TypesSpec.hs +++ b/test/TypesSpec.hs @@ -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