shortened goalie edit header
This commit is contained in:
parent
d7879a92af
commit
7ff16b8ac2
|
@ -27,6 +27,7 @@ import Data.Maybe (fromMaybe)
|
|||
import Lens.Micro ((^.))
|
||||
import UI.NCurses as C
|
||||
|
||||
import Mtlstats.Helpers.Goalie
|
||||
import Mtlstats.Menu
|
||||
import Mtlstats.Menu.EditGoalie
|
||||
import Mtlstats.Prompt
|
||||
|
@ -118,20 +119,4 @@ header :: ProgState -> C.Update ()
|
|||
header s = C.drawString $ fromMaybe "" $ do
|
||||
gid <- s^.progMode.editGoalieStateL.egsSelectedGoalie
|
||||
g <- nth gid $ s^.database.dbGoalies
|
||||
Just $ unlines
|
||||
[ " Goalie number: " ++ show (g^.gNumber)
|
||||
, " Goalie name: " ++ g^.gName
|
||||
, " YTD games played: " ++ show (g^.gYtd.gsGames)
|
||||
, " YTD mins played: " ++ show (g^.gYtd.gsMinsPlayed)
|
||||
, " YTD goals allowed: " ++ show (g^.gYtd.gsGoalsAllowed)
|
||||
, " YTD wins: " ++ show (g^.gYtd.gsWins)
|
||||
, " YTD losses: " ++ show (g^.gYtd.gsLosses)
|
||||
, " YTD ties: " ++ show (g^.gYtd.gsTies)
|
||||
, " Lifetime games played: " ++ show (g^.gLifetime.gsGames)
|
||||
, " Lifetime mins played: " ++ show (g^.gLifetime.gsMinsPlayed)
|
||||
, "Lifetime goals allowed: " ++ show (g^.gLifetime.gsGoalsAllowed)
|
||||
, " Lifetime wins: " ++ show (g^.gLifetime.gsWins)
|
||||
, " Lifetime losses: " ++ show (g^.gLifetime.gsLosses)
|
||||
, " Lifetime ties: " ++ show (g^.gLifetime.gsTies)
|
||||
, ""
|
||||
]
|
||||
Just $ goalieDetails g ++ "\n"
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
{- |
|
||||
|
||||
mtlstats
|
||||
Copyright (C) 2019 Rhéal Lamothe
|
||||
<rheal.lamothe@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or (at
|
||||
your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-}
|
||||
|
||||
module Mtlstats.Helpers.Goalie (goalieDetails) where
|
||||
|
||||
import Lens.Micro ((^.))
|
||||
|
||||
import Mtlstats.Format
|
||||
import Mtlstats.Types
|
||||
|
||||
-- | Provides a detailed 'String' describing a 'Goalie'
|
||||
goalieDetails :: Goalie -> String
|
||||
goalieDetails g = let
|
||||
header = unlines $ labelTable
|
||||
[ ( "Number", show $ g^.gNumber )
|
||||
, ( "Name", g^.gName )
|
||||
]
|
||||
|
||||
body = unlines $ numTable ["YTD", "Lifetime"] $ map
|
||||
(\(label, lens) -> (label, [g^.gYtd.lens, g^.gLifetime.lens]))
|
||||
[ ( "Games played", gsGames )
|
||||
, ( "Mins played", gsMinsPlayed )
|
||||
, ( "Goals allowed", gsGoalsAllowed )
|
||||
, ( "Wins", gsWins )
|
||||
, ( "Losses", gsLosses )
|
||||
, ( "Ties", gsTies )
|
||||
]
|
||||
|
||||
in header ++ "\n" ++ body
|
|
@ -0,0 +1,66 @@
|
|||
{-
|
||||
|
||||
mtlstats
|
||||
Copyright (C) 2019 Rhéal Lamothe
|
||||
<rheal.lamothe@gmail.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or (at
|
||||
your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
-}
|
||||
|
||||
module Helpers.GoalieSpec (spec) where
|
||||
|
||||
import Lens.Micro ((&), (.~), (%~))
|
||||
import Test.Hspec (Spec, describe, it, shouldBe)
|
||||
|
||||
import Mtlstats.Helpers.Goalie
|
||||
import Mtlstats.Types
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "Goalie"
|
||||
goalieDetailsSpec
|
||||
|
||||
goalieDetailsSpec :: Spec
|
||||
goalieDetailsSpec = describe "goalieDetails" $ let
|
||||
input = newGoalie 1 "Joe"
|
||||
& gYtd
|
||||
%~ ( gsGames .~ 2 )
|
||||
. ( gsMinsPlayed .~ 3 )
|
||||
. ( gsGoalsAllowed .~ 4 )
|
||||
. ( gsWins .~ 5 )
|
||||
. ( gsLosses .~ 6 )
|
||||
. ( gsTies .~ 7 )
|
||||
& gLifetime
|
||||
%~ ( gsGames .~ 8 )
|
||||
. ( gsMinsPlayed .~ 9 )
|
||||
. ( gsGoalsAllowed .~ 10 )
|
||||
. ( gsWins .~ 11 )
|
||||
. ( gsLosses .~ 12 )
|
||||
. ( gsTies .~ 13 )
|
||||
|
||||
expected = unlines
|
||||
[ "Number: 1"
|
||||
, " Name: Joe"
|
||||
, ""
|
||||
, " YTD Lifetime"
|
||||
, " Games played 2 8"
|
||||
, " Mins played 3 9"
|
||||
, "Goals allowed 4 10"
|
||||
, " Wins 5 11"
|
||||
, " Losses 6 12"
|
||||
, " Ties 7 13"
|
||||
]
|
||||
|
||||
in it "should format the output correctly" $
|
||||
goalieDetails input `shouldBe` expected
|
|
@ -23,8 +23,10 @@ module HelpersSpec (spec) where
|
|||
|
||||
import Test.Hspec (Spec, describe)
|
||||
|
||||
import qualified Helpers.GoalieSpec as Goalie
|
||||
import qualified Helpers.PlayerSpec as Player
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "Helper"
|
||||
spec = describe "Helper" $ do
|
||||
Player.spec
|
||||
Goalie.spec
|
||||
|
|
Loading…
Reference in New Issue
Block a user