From 95e74accd4290ac9a529272a4b93922c81807a48 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 30 Jan 2020 23:39:20 -0500 Subject: [PATCH] edit lifetime stats on new player creation --- src/Mtlstats/Control/CreatePlayer.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Mtlstats/Control/CreatePlayer.hs b/src/Mtlstats/Control/CreatePlayer.hs index afebf22..01b8275 100644 --- a/src/Mtlstats/Control/CreatePlayer.hs +++ b/src/Mtlstats/Control/CreatePlayer.hs @@ -24,7 +24,7 @@ module Mtlstats.Control.CreatePlayer (createPlayerC) where import Control.Monad (join) import Control.Monad.Trans.State (gets, modify) import Data.Maybe (fromJust) -import Lens.Micro ((^.)) +import Lens.Micro ((^.), (.~), (?~), (%~), to) import qualified UI.NCurses as C import Mtlstats.Actions @@ -76,8 +76,14 @@ confirmCreatePlayerC = Controller , handleController = \e -> do case ynHandler e of Just True -> do - modify addPlayer - join $ gets (^.progMode.createPlayerStateL.cpsSuccessCallback) + pid <- gets (^.database.dbPlayers.to length) + cb <- gets (^.progMode.createPlayerStateL.cpsSuccessCallback) + modify + $ (progMode.editPlayerStateL + %~ (epsSelectedPlayer ?~ pid) + . (epsMode .~ EPLtGoals True) + . (epsCallback .~ cb)) + . addPlayer Just False -> join $ gets (^.progMode.createPlayerStateL.cpsFailureCallback) Nothing -> return ()