only edit player lifetime stats if rookie
...on new player creation
This commit is contained in:
parent
c22849bb3b
commit
2941998058
|
@ -21,7 +21,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
module Mtlstats.Control.CreatePlayer (createPlayerC) where
|
module Mtlstats.Control.CreatePlayer (createPlayerC) where
|
||||||
|
|
||||||
import Control.Monad (join)
|
|
||||||
import Control.Monad.Trans.State (gets, modify)
|
import Control.Monad.Trans.State (gets, modify)
|
||||||
import Lens.Micro ((^.), (.~), (?~), (%~), to)
|
import Lens.Micro ((^.), (.~), (?~), (%~), to)
|
||||||
import qualified UI.NCurses as C
|
import qualified UI.NCurses as C
|
||||||
|
@ -76,18 +75,22 @@ confirmCreatePlayerC = Controller
|
||||||
]
|
]
|
||||||
return C.CursorInvisible
|
return C.CursorInvisible
|
||||||
, handleController = \e -> do
|
, handleController = \e -> do
|
||||||
|
cps <- gets (^.progMode.createPlayerStateL)
|
||||||
|
let
|
||||||
|
success = cps^.cpsSuccessCallback
|
||||||
|
failure = cps^.cpsFailureCallback
|
||||||
case ynHandler e of
|
case ynHandler e of
|
||||||
Just True -> do
|
Just True -> do
|
||||||
pid <- gets (^.database.dbPlayers.to length)
|
pid <- gets (^.database.dbPlayers.to length)
|
||||||
cb <- gets (^.progMode.createPlayerStateL.cpsSuccessCallback)
|
let rookie = cps^.cpsRookieFlag == Just True
|
||||||
modify
|
modify addPlayer
|
||||||
$ (progMode.editPlayerStateL
|
if rookie
|
||||||
|
then success
|
||||||
|
else modify (progMode.editPlayerStateL
|
||||||
%~ (epsSelectedPlayer ?~ pid)
|
%~ (epsSelectedPlayer ?~ pid)
|
||||||
. (epsMode .~ EPLtGoals True)
|
. (epsMode .~ EPLtGoals True)
|
||||||
. (epsCallback .~ cb))
|
. (epsCallback .~ success))
|
||||||
. addPlayer
|
Just False -> failure
|
||||||
Just False ->
|
|
||||||
join $ gets (^.progMode.createPlayerStateL.cpsFailureCallback)
|
|
||||||
Nothing -> return ()
|
Nothing -> return ()
|
||||||
return True
|
return True
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user