add game stats to report
This commit is contained in:
parent
de7f3f7a3e
commit
8424d5f40c
|
@ -21,12 +21,14 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
module Mtlstats.Report (report, gameDate) where
|
module Mtlstats.Report (report, gameDate) where
|
||||||
|
|
||||||
|
import qualified Data.Map as M
|
||||||
import Data.Maybe (fromMaybe)
|
import Data.Maybe (fromMaybe)
|
||||||
import Lens.Micro ((^.))
|
import Lens.Micro ((^.))
|
||||||
|
|
||||||
import Mtlstats.Config
|
import Mtlstats.Config
|
||||||
import Mtlstats.Format
|
import Mtlstats.Format
|
||||||
import Mtlstats.Types
|
import Mtlstats.Types
|
||||||
|
import Mtlstats.Util
|
||||||
|
|
||||||
-- | Generates the report
|
-- | Generates the report
|
||||||
report
|
report
|
||||||
|
@ -37,18 +39,24 @@ report
|
||||||
-> String
|
-> String
|
||||||
report width s = unlines $ fromMaybe [] $ do
|
report 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
|
||||||
Just
|
pStats <- mapM
|
||||||
|
(\(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
|
||||||
|
@ -78,7 +86,26 @@ report width s = unlines $ fromMaybe [] $ do
|
||||||
, centre width
|
, centre width
|
||||||
$ left 11 "TOTALS"
|
$ left 11 "TOTALS"
|
||||||
++ showStats tStats
|
++ showStats tStats
|
||||||
]
|
, ""
|
||||||
|
, centre width "GAME STATISTICS"
|
||||||
|
, ""
|
||||||
|
, centre width
|
||||||
|
$ "NO. "
|
||||||
|
++ left 20 "PLAYER"
|
||||||
|
++ right 3 "G"
|
||||||
|
++ right 6 "A"
|
||||||
|
++ right 6 "P"
|
||||||
|
++ right 6 "PM"
|
||||||
|
] ++ map
|
||||||
|
(\(p, stats) -> centre width
|
||||||
|
$ right 2 (show $ p^.pNumber)
|
||||||
|
++ " "
|
||||||
|
++ left 20 (p^.pName)
|
||||||
|
++ right 3 (show $ stats^.psGoals)
|
||||||
|
++ right 6 (show $ stats^.psAssists)
|
||||||
|
++ right 6 (show $ pPoints stats)
|
||||||
|
++ right 6 (show $ stats^.psPMin))
|
||||||
|
pStats
|
||||||
|
|
||||||
gameDate :: GameState -> String
|
gameDate :: GameState -> String
|
||||||
gameDate gs = fromMaybe "" $ do
|
gameDate gs = fromMaybe "" $ do
|
||||||
|
|
Loading…
Reference in New Issue
Block a user