split report into standings and game stats
This commit is contained in:
parent
83f951f7e4
commit
5f53413ef7
@ -37,26 +37,26 @@ report
|
|||||||
-> ProgState
|
-> ProgState
|
||||||
-- ^ The program state
|
-- ^ The program state
|
||||||
-> String
|
-> String
|
||||||
report width s = unlines $ fromMaybe [] $ do
|
report width s
|
||||||
|
= standingsReport width s
|
||||||
|
++ "\n"
|
||||||
|
++ gameStatsReport width s
|
||||||
|
|
||||||
|
standingsReport :: Int -> ProgState -> String
|
||||||
|
standingsReport width s = unlines $ fromMaybe [] $ do
|
||||||
let
|
let
|
||||||
db = s^.database
|
db = s^.database
|
||||||
gs = s^.progMode.gameStateL
|
gs = s^.progMode.gameStateL
|
||||||
gNum = db^.dbGames
|
gNum = db^.dbGames
|
||||||
date = gameDate gs
|
date = gameDate gs
|
||||||
hTeam = homeTeam gs
|
hTeam = homeTeam gs
|
||||||
aTeam = awayTeam gs
|
aTeam = awayTeam gs
|
||||||
hStats = db^.dbHomeGameStats
|
hStats = db^.dbHomeGameStats
|
||||||
aStats = db^.dbAwayGameStats
|
aStats = db^.dbAwayGameStats
|
||||||
tStats = addGameStats hStats aStats
|
tStats = addGameStats hStats aStats
|
||||||
players = db^.dbPlayers
|
|
||||||
hScore <- gs^.homeScore
|
hScore <- gs^.homeScore
|
||||||
aScore <- gs^.awayScore
|
aScore <- gs^.awayScore
|
||||||
pStats <- mapM
|
Just
|
||||||
(\(n, stats) -> do
|
|
||||||
player <- nth n players
|
|
||||||
Just (player, stats))
|
|
||||||
(M.toList $ gs^.gamePlayerStats)
|
|
||||||
Just $
|
|
||||||
[ overlay
|
[ overlay
|
||||||
("GAME NUMBER " ++ padNum 2 gNum)
|
("GAME NUMBER " ++ padNum 2 gNum)
|
||||||
(centre width
|
(centre width
|
||||||
@ -86,12 +86,25 @@ report width s = unlines $ fromMaybe [] $ do
|
|||||||
, centre width
|
, centre width
|
||||||
$ left 11 "TOTALS"
|
$ left 11 "TOTALS"
|
||||||
++ showStats tStats
|
++ showStats tStats
|
||||||
, ""
|
]
|
||||||
, centre width "GAME STATISTICS"
|
|
||||||
|
gameStatsReport :: Int -> ProgState -> String
|
||||||
|
gameStatsReport width s = unlines $ fromMaybe [] $ do
|
||||||
|
pStats <- mapM
|
||||||
|
(\(pid, stats) -> do
|
||||||
|
p <- nth pid $ s^.database.dbPlayers
|
||||||
|
Just (p, stats))
|
||||||
|
(M.toList $ s^.progMode.gameStateL.gamePlayerStats)
|
||||||
|
let
|
||||||
|
nameWidth = succ $ maximum $ 10 : map
|
||||||
|
(length . (^.pName) . fst)
|
||||||
|
pStats
|
||||||
|
Just $
|
||||||
|
[ centre width "GAME STATISTICS"
|
||||||
, ""
|
, ""
|
||||||
, centre width
|
, centre width
|
||||||
$ "NO. "
|
$ "NO. "
|
||||||
++ left 20 "PLAYER"
|
++ left nameWidth "PLAYER"
|
||||||
++ right 3 "G"
|
++ right 3 "G"
|
||||||
++ right 6 "A"
|
++ right 6 "A"
|
||||||
++ right 6 "P"
|
++ right 6 "P"
|
||||||
@ -100,7 +113,7 @@ report width s = unlines $ fromMaybe [] $ do
|
|||||||
(\(p, stats) -> centre width
|
(\(p, stats) -> centre width
|
||||||
$ right 2 (show $ p^.pNumber)
|
$ right 2 (show $ p^.pNumber)
|
||||||
++ " "
|
++ " "
|
||||||
++ left 20 (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 $ pPoints stats)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user