From 4e9b3f635d5b60871052e5e24085bb73906d7433 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Fri, 1 Nov 2019 06:30:37 -0400 Subject: [PATCH] implemented year-to-date goal editing --- src/Mtlstats/Control/EditPlayer.hs | 7 ++++++- src/Mtlstats/Prompt/EditPlayer.hs | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Control/EditPlayer.hs b/src/Mtlstats/Control/EditPlayer.hs index 46218ba..0691af8 100644 --- a/src/Mtlstats/Control/EditPlayer.hs +++ b/src/Mtlstats/Control/EditPlayer.hs @@ -95,7 +95,12 @@ positionC = Controller } ytdGoalsC :: Controller -ytdGoalsC = undefined +ytdGoalsC = Controller + { drawController = drawPrompt editPlayerYtdGoalsPrompt + , handleController = \e -> do + promptHandler editPlayerYtdGoalsPrompt e + return True + } ytdAssistsC :: Controller ytdAssistsC = undefined diff --git a/src/Mtlstats/Prompt/EditPlayer.hs b/src/Mtlstats/Prompt/EditPlayer.hs index 376c9f9..f466ddc 100644 --- a/src/Mtlstats/Prompt/EditPlayer.hs +++ b/src/Mtlstats/Prompt/EditPlayer.hs @@ -23,6 +23,7 @@ module Mtlstats.Prompt.EditPlayer ( editPlayerNumPrompt , editPlayerNamePrompt , editPlayerPosPrompt + , editPlayerYtdGoalsPrompt ) where import Control.Monad.Extra (whenJustM) @@ -48,6 +49,11 @@ editPlayerPosPrompt :: Prompt editPlayerPosPrompt = strPrompt "Player position: " $ editPlayer . (pPosition .~) +-- | Prompt to edit a player's year-to-date goals +editPlayerYtdGoalsPrompt :: Prompt +editPlayerYtdGoalsPrompt = numPrompt "Year-to-date goals: " $ + editPlayer . (pYtd.psGoals .~) + editPlayer :: (Player -> Player) -> Action () editPlayer f = whenJustM (gets (^.progMode.editPlayerStateL.epsSelectedPlayer)) $ \pid ->