From 5bf5a605aaa05848404bf58b2f6c2b71d14b017d Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Fri, 1 Nov 2019 06:22:48 -0400 Subject: [PATCH] implemented editPlayerNamePrompt --- src/Mtlstats/Prompt/EditPlayer.hs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/Mtlstats/Prompt/EditPlayer.hs b/src/Mtlstats/Prompt/EditPlayer.hs index c4e5160..bb439e3 100644 --- a/src/Mtlstats/Prompt/EditPlayer.hs +++ b/src/Mtlstats/Prompt/EditPlayer.hs @@ -34,12 +34,17 @@ import Mtlstats.Util -- | Prompt to edit a player's number editPlayerNumPrompt :: Prompt -editPlayerNumPrompt = numPrompt "Player number: " $ \n -> - whenJustM (gets (^.progMode.editPlayerStateL.epsSelectedPlayer)) $ \pid -> - modify - $ (database.dbPlayers %~ modifyNth pid (pNumber .~ n)) - . (progMode.editPlayerStateL.epsMode .~ EPMenu) +editPlayerNumPrompt = numPrompt "Player number: " $ + editPlayer . (pNumber .~) -- | Prompt to edit a player's name editPlayerNamePrompt :: Prompt -editPlayerNamePrompt = undefined +editPlayerNamePrompt = strPrompt "Player name: " $ + editPlayer . (pName .~) + +editPlayer :: (Player -> Player) -> Action () +editPlayer f = + whenJustM (gets (^.progMode.editPlayerStateL.epsSelectedPlayer)) $ \pid -> + modify + $ (database.dbPlayers %~ modifyNth pid f) + . (progMode.editPlayerStateL.epsMode .~ EPMenu)