refactored standingsReport
This commit is contained in:
parent
5979856578
commit
3560aa7595
|
@ -60,37 +60,53 @@ standingsReport width s = fromMaybe [] $ do
|
||||||
tStats = addGameStats hStats aStats
|
tStats = addGameStats hStats aStats
|
||||||
hScore <- gs^.homeScore
|
hScore <- gs^.homeScore
|
||||||
aScore <- gs^.awayScore
|
aScore <- gs^.awayScore
|
||||||
Just
|
let
|
||||||
[ overlay
|
rHeader =
|
||||||
("GAME NUMBER " ++ padNum 2 gNum)
|
[ overlay
|
||||||
(centre width
|
("GAME NUMBER " ++ padNum 2 gNum)
|
||||||
$ aTeam ++ " " ++ show aScore ++ " AT "
|
(centre width
|
||||||
++ hTeam ++ " " ++ show hScore)
|
$ aTeam ++ " " ++ show aScore ++ " AT "
|
||||||
, date
|
++ hTeam ++ " " ++ show hScore)
|
||||||
, centre width "STANDINGS"
|
, date
|
||||||
, ""
|
, centre width "STANDINGS"
|
||||||
, centre width
|
, ""
|
||||||
$ left 11 myTeam
|
]
|
||||||
++ right 2 "G"
|
|
||||||
++ right 4 "W"
|
tHeader =
|
||||||
++ right 4 "L"
|
[ CellText myTeam
|
||||||
++ right 4 "OT"
|
, CellText " G"
|
||||||
++ right 4 "GF"
|
, CellText " W"
|
||||||
++ right 4 "GA"
|
, CellText " L"
|
||||||
++ right 4 "P"
|
, CellText " OT"
|
||||||
, centre width
|
, CellText " GF"
|
||||||
$ left 11 "HOME"
|
, CellText " GA"
|
||||||
++ showStats hStats
|
, CellText " P"
|
||||||
, centre width
|
]
|
||||||
$ left 11 "ROAD"
|
|
||||||
++ showStats aStats
|
rowCells stats =
|
||||||
, centre width
|
[ CellText $ show $ gmsGames stats
|
||||||
$ replicate 11 ' '
|
, CellText $ show $ stats^.gmsWins
|
||||||
++ replicate (2 + 4 * 6) '-'
|
, CellText $ show $ stats^.gmsLosses
|
||||||
, centre width
|
, CellText $ show $ stats^.gmsOvertime
|
||||||
$ left 11 "TOTALS"
|
, CellText $ show $ stats^.gmsGoalsFor
|
||||||
++ showStats tStats
|
, CellText $ show $ stats^.gmsGoalsAgainst
|
||||||
]
|
, CellText $ show $ gmsPoints stats
|
||||||
|
]
|
||||||
|
|
||||||
|
body =
|
||||||
|
[ CellText "HOME" : rowCells hStats
|
||||||
|
, CellText "ROAD" : rowCells aStats
|
||||||
|
]
|
||||||
|
|
||||||
|
separator = CellText "" : replicate 7 (CellFill '-')
|
||||||
|
totals = CellText "TOTALS" : rowCells tStats
|
||||||
|
|
||||||
|
table = map (centre width) $
|
||||||
|
complexTable
|
||||||
|
(left : repeat right)
|
||||||
|
(tHeader : body ++ [separator, totals])
|
||||||
|
|
||||||
|
Just $ rHeader ++ table
|
||||||
|
|
||||||
gameStatsReport :: Int -> ProgState -> [String]
|
gameStatsReport :: Int -> ProgState -> [String]
|
||||||
gameStatsReport width s = playerReport width "GAME" $
|
gameStatsReport width s = playerReport width "GAME" $
|
||||||
|
@ -166,13 +182,3 @@ playerNameColWidth :: [Player] -> Int
|
||||||
playerNameColWidth = foldr
|
playerNameColWidth = foldr
|
||||||
(\player current -> max current $ succ $ length $ player^.pName)
|
(\player current -> max current $ succ $ length $ player^.pName)
|
||||||
10
|
10
|
||||||
|
|
||||||
showStats :: GameStats -> String
|
|
||||||
showStats gs
|
|
||||||
= right 2 (show $ gmsGames gs)
|
|
||||||
++ right 4 (show $ gs^.gmsWins)
|
|
||||||
++ right 4 (show $ gs^.gmsLosses)
|
|
||||||
++ right 4 (show $ gs^.gmsOvertime)
|
|
||||||
++ right 4 (show $ gs^.gmsGoalsFor)
|
|
||||||
++ right 4 (show $ gs^.gmsGoalsAgainst)
|
|
||||||
++ right 4 (show $ gmsPoints gs)
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user