From 59d48ec154e64c4b85d8eef3b8e6b2d8b7c2f92c Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Tue, 17 Dec 2019 11:32:32 -0500 Subject: [PATCH 01/10] added EditMenu mode --- src/Mtlstats/Control.hs | 8 ++++++-- src/Mtlstats/Types.hs | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Mtlstats/Control.hs b/src/Mtlstats/Control.hs index b8521d7..d6c3d95 100644 --- a/src/Mtlstats/Control.hs +++ b/src/Mtlstats/Control.hs @@ -41,9 +41,10 @@ import Mtlstats.Types -- run dispatch :: ProgState -> Controller dispatch s = case s^.progMode of - MainMenu -> mainMenuC - NewSeason -> newSeasonC + MainMenu -> mainMenuC + NewSeason -> newSeasonC NewGame gs -> newGameC gs + EditMenu -> editMenuC CreatePlayer cps | null $ cps^.cpsNumber -> getPlayerNumC | null $ cps^.cpsName -> getPlayerNameC @@ -70,6 +71,9 @@ newSeasonC = Controller return True } +editMenuC :: Controller +editMenuC = undefined + getPlayerNumC :: Controller getPlayerNumC = Controller { drawController = drawPrompt playerNumPrompt diff --git a/src/Mtlstats/Types.hs b/src/Mtlstats/Types.hs index 04f612b..6c5bc20 100644 --- a/src/Mtlstats/Types.hs +++ b/src/Mtlstats/Types.hs @@ -230,6 +230,7 @@ data ProgMode = MainMenu | NewSeason | NewGame GameState + | EditMenu | CreatePlayer CreatePlayerState | CreateGoalie CreateGoalieState | EditPlayer EditPlayerState @@ -239,6 +240,7 @@ instance Show ProgMode where show MainMenu = "MainMenu" show NewSeason = "NewSeason" show (NewGame _) = "NewGame" + show EditMenu = "EditMenu" show (CreatePlayer _) = "CreatePlayer" show (CreateGoalie _) = "CreateGoalie" show (EditPlayer _) = "EditPlayer" From 8988ad9146a2f7c31b25c962118977e7c97392c2 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Tue, 17 Dec 2019 11:38:35 -0500 Subject: [PATCH 02/10] implemented Mtlstats.Control.editMenuC --- src/Mtlstats/Control.hs | 2 +- src/Mtlstats/Menu.hs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Mtlstats/Control.hs b/src/Mtlstats/Control.hs index d6c3d95..4d5b827 100644 --- a/src/Mtlstats/Control.hs +++ b/src/Mtlstats/Control.hs @@ -72,7 +72,7 @@ newSeasonC = Controller } editMenuC :: Controller -editMenuC = undefined +editMenuC = menuController editMenu getPlayerNumC :: Controller getPlayerNumC = Controller diff --git a/src/Mtlstats/Menu.hs b/src/Mtlstats/Menu.hs index 77c6f63..76e6a17 100644 --- a/src/Mtlstats/Menu.hs +++ b/src/Mtlstats/Menu.hs @@ -31,7 +31,8 @@ module Mtlstats.Menu ( newSeasonMenu, gameMonthMenu, gameTypeMenu, - gameGoalieMenu + gameGoalieMenu, + editMenu ) where import Control.Monad.IO.Class (liftIO) @@ -186,3 +187,7 @@ gameGoalieMenu s = let (\(ch, (gid, goalie)) -> MenuItem ch (goalieSummary goalie) $ modify $ GI.setGameGoalie gid) $ zip ['1'..] goalies + +-- | The edit menu +editMenu :: Menu () +editMenu = undefined From 1d6a4aa7f3f911d902be061d4d9988aa7b68560a Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Tue, 17 Dec 2019 11:48:01 -0500 Subject: [PATCH 03/10] implemented editMenu --- src/Mtlstats/Menu.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Menu.hs b/src/Mtlstats/Menu.hs index 76e6a17..28c57da 100644 --- a/src/Mtlstats/Menu.hs +++ b/src/Mtlstats/Menu.hs @@ -190,4 +190,11 @@ gameGoalieMenu s = let -- | The edit menu editMenu :: Menu () -editMenu = undefined +editMenu = Menu "*** EDIT ***" () + [ MenuItem '1' "Edit Player" $ + modify editPlayer + , MenuItem '2' "Edit Goalie" $ + modify editGoalie + , MenuItem 'R' "Return to Main Menu" $ + modify backHome + ] From 9980a095edeab06fe16d8238bd2f6a1e7588c1d7 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Tue, 17 Dec 2019 12:04:11 -0500 Subject: [PATCH 04/10] added edit menu to main menu --- src/Mtlstats/Actions.hs | 5 +++++ src/Mtlstats/Menu.hs | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Mtlstats/Actions.hs b/src/Mtlstats/Actions.hs index fc03ec1..def83fd 100644 --- a/src/Mtlstats/Actions.hs +++ b/src/Mtlstats/Actions.hs @@ -30,6 +30,7 @@ module Mtlstats.Actions , removeChar , createPlayer , createGoalie + , edit , editPlayer , editGoalie , addPlayer @@ -97,6 +98,10 @@ createGoalie = let & cgsFailureCallback .~ callback in progMode .~ CreateGoalie cgs +-- | Launches the edit menu +edit :: ProgState -> ProgState +edit = undefined + -- | Starts the player editing process editPlayer :: ProgState -> ProgState editPlayer = progMode .~ EditPlayer newEditPlayerState diff --git a/src/Mtlstats/Menu.hs b/src/Mtlstats/Menu.hs index 28c57da..ef9594a 100644 --- a/src/Mtlstats/Menu.hs +++ b/src/Mtlstats/Menu.hs @@ -118,10 +118,8 @@ mainMenu = Menu "*** MAIN MENU ***" True modify createPlayer >> return True , MenuItem '4' "Create Goalie" $ modify createGoalie >> return True - , MenuItem '5' "Edit Player" $ - modify editPlayer >> return True - , MenuItem '6' "Edit Goalie" $ - modify editGoalie >> return True + , MenuItem '5' "Edit" $ + modify edit >> return True , MenuItem 'X' "Exit" $ do db <- gets $ view database liftIO $ do From a44ecc5e24b6d7a1e958849ddae042e4863cbe36 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Tue, 17 Dec 2019 12:16:26 -0500 Subject: [PATCH 05/10] implemented edit --- src/Mtlstats/Actions.hs | 2 +- test/ActionsSpec.hs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions.hs b/src/Mtlstats/Actions.hs index def83fd..e3948ea 100644 --- a/src/Mtlstats/Actions.hs +++ b/src/Mtlstats/Actions.hs @@ -100,7 +100,7 @@ createGoalie = let -- | Launches the edit menu edit :: ProgState -> ProgState -edit = undefined +edit = progMode .~ EditMenu -- | Starts the player editing process editPlayer :: ProgState -> ProgState diff --git a/test/ActionsSpec.hs b/test/ActionsSpec.hs index 8f6b764..0f6e1d9 100644 --- a/test/ActionsSpec.hs +++ b/test/ActionsSpec.hs @@ -52,6 +52,7 @@ spec = describe "Mtlstats.Actions" $ do removeCharSpec createPlayerSpec createGoalieSpec + editSpec editPlayerSpec editGoalieSpec addPlayerSpec @@ -198,6 +199,12 @@ createGoalieSpec = describe "createGoalie" $ s = createGoalie newProgState in show (s^.progMode) `shouldBe` "CreateGoalie" +editSpec :: Spec +editSpec = describe "edit" $ + it "should change the mode to EditMenu" $ let + ps = edit newProgState + in show (ps^.progMode) `shouldBe` "EditMenu" + editPlayerSpec :: Spec editPlayerSpec = describe "editPlayer" $ it "should change the mode appropriately" $ let From adf09c2cc4f3b105dd33ac7b6f750f3f623ad2de Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Tue, 17 Dec 2019 12:23:53 -0500 Subject: [PATCH 06/10] moved player/goalie creation to edit menu --- src/Mtlstats/Menu.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Mtlstats/Menu.hs b/src/Mtlstats/Menu.hs index ef9594a..a88cbed 100644 --- a/src/Mtlstats/Menu.hs +++ b/src/Mtlstats/Menu.hs @@ -114,11 +114,7 @@ mainMenu = Menu "*** MAIN MENU ***" True modify startNewSeason >> return True , MenuItem '2' "New Game" $ modify startNewGame >> return True - , MenuItem '3' "Create Player" $ - modify createPlayer >> return True - , MenuItem '4' "Create Goalie" $ - modify createGoalie >> return True - , MenuItem '5' "Edit" $ + , MenuItem '3' "Edit" $ modify edit >> return True , MenuItem 'X' "Exit" $ do db <- gets $ view database @@ -189,9 +185,13 @@ gameGoalieMenu s = let -- | The edit menu editMenu :: Menu () editMenu = Menu "*** EDIT ***" () - [ MenuItem '1' "Edit Player" $ + [ MenuItem '1' "Create Player" $ + modify createPlayer + , MenuItem '2' "Create Goalie" $ + modify createGoalie + , MenuItem '3' "Edit Player" $ modify editPlayer - , MenuItem '2' "Edit Goalie" $ + , MenuItem '4' "Edit Goalie" $ modify editGoalie , MenuItem 'R' "Return to Main Menu" $ modify backHome From 235dd4e6113811ed9ed3aeaca5f888abf92a36d6 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Tue, 17 Dec 2019 12:30:55 -0500 Subject: [PATCH 07/10] return to edit menu after player/goalie creation --- src/Mtlstats/Actions.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mtlstats/Actions.hs b/src/Mtlstats/Actions.hs index e3948ea..e5f9fdd 100644 --- a/src/Mtlstats/Actions.hs +++ b/src/Mtlstats/Actions.hs @@ -83,7 +83,7 @@ removeChar = inputBuffer %~ \case -- | Starts player creation mode createPlayer :: ProgState -> ProgState createPlayer = let - callback = modify $ progMode .~ MainMenu + callback = modify edit cps = newCreatePlayerState & cpsSuccessCallback .~ callback & cpsFailureCallback .~ callback @@ -92,7 +92,7 @@ createPlayer = let -- | Starts goalie creation mode createGoalie :: ProgState -> ProgState createGoalie = let - callback = modify $ progMode .~ MainMenu + callback = modify edit cgs = newCreateGoalieState & cgsSuccessCallback .~ callback & cgsFailureCallback .~ callback From 3aedd01b08278436f1e67a939326e4ee6a7dbdc6 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Tue, 17 Dec 2019 22:47:17 -0500 Subject: [PATCH 08/10] make player/goalie edit return to edit menu on completion --- src/Mtlstats/Menu/EditGoalie.hs | 10 +++++----- src/Mtlstats/Menu/EditPlayer.hs | 8 +++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Mtlstats/Menu/EditGoalie.hs b/src/Mtlstats/Menu/EditGoalie.hs index ce5b531..218bf14 100644 --- a/src/Mtlstats/Menu/EditGoalie.hs +++ b/src/Mtlstats/Menu/EditGoalie.hs @@ -26,19 +26,19 @@ module Mtlstats.Menu.EditGoalie ) where import Control.Monad.Trans.State (modify) -import Data.Maybe (maybe) import Lens.Micro ((.~)) +import Mtlstats.Actions import Mtlstats.Types import Mtlstats.Types.Menu -- | The 'Goalie' edit menu editGoalieMenu :: Menu () editGoalieMenu = Menu "*** EDIT GOALTENDER ***" () $ map - (\(key, label, val) -> MenuItem key label $ modify $ maybe - (progMode .~ MainMenu) - (progMode.editGoalieStateL.egsMode .~) - val) + (\(ch, label, mode) -> MenuItem ch label $ + modify $ case mode of + Nothing -> edit + Just m -> progMode.editGoalieStateL.egsMode .~ m) -- key, label, value [ ( '1', "Edit number", Just EGNumber ) , ( '2', "Edit name", Just EGName ) diff --git a/src/Mtlstats/Menu/EditPlayer.hs b/src/Mtlstats/Menu/EditPlayer.hs index 8167f88..57d008c 100644 --- a/src/Mtlstats/Menu/EditPlayer.hs +++ b/src/Mtlstats/Menu/EditPlayer.hs @@ -28,15 +28,17 @@ module Mtlstats.Menu.EditPlayer import Control.Monad.Trans.State (modify) import Lens.Micro ((.~)) +import Mtlstats.Actions import Mtlstats.Types import Mtlstats.Types.Menu -- | The 'Player' edit menu editPlayerMenu :: Menu () editPlayerMenu = Menu "*** EDIT PLAYER ***" () $ map - (\(ch, label, mode) -> MenuItem ch label $ case mode of - Nothing -> modify $ progMode .~ MainMenu - Just m -> modify $ progMode.editPlayerStateL.epsMode .~ m) + (\(ch, label, mode) -> MenuItem ch label $ + modify $ case mode of + Nothing -> edit + Just m -> progMode.editPlayerStateL.epsMode .~ m) -- key, label, value [ ( '1', "Edit number", Just EPNumber ) , ( '2', "Edit name", Just EPName ) From 18ba758c0c5a40559ebe9f8f998bbff81d6022bf Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Tue, 17 Dec 2019 22:50:39 -0500 Subject: [PATCH 09/10] changed return wording on player/goalie edit menus --- src/Mtlstats/Menu/EditGoalie.hs | 2 +- src/Mtlstats/Menu/EditPlayer.hs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mtlstats/Menu/EditGoalie.hs b/src/Mtlstats/Menu/EditGoalie.hs index 218bf14..38e15c3 100644 --- a/src/Mtlstats/Menu/EditGoalie.hs +++ b/src/Mtlstats/Menu/EditGoalie.hs @@ -44,7 +44,7 @@ editGoalieMenu = Menu "*** EDIT GOALTENDER ***" () $ map , ( '2', "Edit name", Just EGName ) , ( '3', "Edit YTD stats", Just EGYtd ) , ( '4', "Edit Lifetime stats", Just EGLifetime ) - , ( 'R', "Return to Main Menu", Nothing ) + , ( 'R', "Return to Edit Menu", Nothing ) ] -- | The 'Goalie' YTD edit menu diff --git a/src/Mtlstats/Menu/EditPlayer.hs b/src/Mtlstats/Menu/EditPlayer.hs index 57d008c..b0a0e0b 100644 --- a/src/Mtlstats/Menu/EditPlayer.hs +++ b/src/Mtlstats/Menu/EditPlayer.hs @@ -45,7 +45,7 @@ editPlayerMenu = Menu "*** EDIT PLAYER ***" () $ map , ( '3', "Edit position", Just EPPosition ) , ( '4', "Edit YTD stats", Just EPYtd ) , ( '5', "Edit lifetime stats", Just EPLifetime ) - , ( 'R', "Finished editing", Nothing ) + , ( 'R', "Return to Edit Menu", Nothing ) ] -- | The 'Player' YTD stats edit menu From 4d41c454a1ed43463261b9de69172fefbd2f4a56 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Tue, 17 Dec 2019 22:52:21 -0500 Subject: [PATCH 10/10] updated change log --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index e5673a8..a9cfe43 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -5,6 +5,7 @@ - Force expected capitalization on player/goalie names - Don't show lifetime totals in report - Sort players in YTD and lifetime reports by points +- Moved player/goalie creation/editing to edit submenu ## 0.8.0 - Bugfix: removed quotation marks from goalie names in report