implemented win/loss/tie tallying

This commit is contained in:
Jonathan Lamothe
2019-11-04 05:44:08 -05:00
parent 4910200c96
commit c6c461f584
2 changed files with 128 additions and 2 deletions
+23 -1
View File
@@ -80,4 +80,26 @@ setGameGoalie
-- ^ The goalie's index
-> ProgState
-> ProgState
setGameGoalie = undefined
setGameGoalie gid s = fromMaybe s $ do
let gs = s^.progMode.gameStateL
won <- gameWon gs
lost <- gameLost gs
tied <- gs^.overtimeFlag
let
w = if won then 1 else 0
l = if lost then 1 else 0
t = if tied then 1 else 0
updateStats gs = gs
& gsWins +~ w
& gsLosses +~ l
& gsTies +~ t
updateGoalie g = g
& gYtd %~ updateStats
& gLifetime %~ updateStats
Just $ s
& database.dbGoalies %~ modifyNth gid updateGoalie
& progMode.gameStateL.gameGoalieStats
%~ updateMap gid newGoalieStats updateStats