diff --git a/src/Mtlstats/Actions.hs b/src/Mtlstats/Actions.hs index e75caa0..f24461a 100644 --- a/src/Mtlstats/Actions.hs +++ b/src/Mtlstats/Actions.hs @@ -32,6 +32,7 @@ module Mtlstats.Actions , validateGameDate , createPlayer , createGoalie + , editPlayer , addPlayer , addGoalie , resetCreatePlayerState @@ -159,6 +160,10 @@ createGoalie = let & cgsFailureCallback .~ callback in progMode .~ CreateGoalie cgs +-- | Starts the player editing process +editPlayer :: ProgState -> ProgState +editPlayer = progMode .~ EditPlayer newEditPlayerState + -- | Adds the entered player to the roster addPlayer :: ProgState -> ProgState addPlayer s = fromMaybe s $ do diff --git a/src/Mtlstats/Menu.hs b/src/Mtlstats/Menu.hs index d1521f7..96a8d6e 100644 --- a/src/Mtlstats/Menu.hs +++ b/src/Mtlstats/Menu.hs @@ -73,7 +73,9 @@ mainMenu = Menu "*** MAIN MENU ***" True modify createPlayer >> return True , MenuItem '4' "Create Goalie" $ modify createGoalie >> return True - , MenuItem '5' "Exit" $ do + , MenuItem '5' "Edit Player" $ + modify editPlayer >> return True + , MenuItem '6' "Exit" $ do db <- gets $ view database liftIO $ do dir <- getAppUserDataDirectory appName diff --git a/src/Mtlstats/Types.hs b/src/Mtlstats/Types.hs index 6a4f1d4..f59ef8e 100644 --- a/src/Mtlstats/Types.hs +++ b/src/Mtlstats/Types.hs @@ -221,6 +221,7 @@ instance Show ProgMode where show (NewGame _) = "NewGame" show (CreatePlayer _) = "CreatePlayer" show (CreateGoalie _) = "CreateGoalie" + show (EditPlayer _) = "EditPlayer" -- | The game state data GameState = GameState diff --git a/test/ActionsSpec.hs b/test/ActionsSpec.hs index 11adbf1..16ec6a4 100644 --- a/test/ActionsSpec.hs +++ b/test/ActionsSpec.hs @@ -57,6 +57,7 @@ spec = describe "Mtlstats.Actions" $ do validateGameDateSpec createPlayerSpec createGoalieSpec + editPlayerSpec addPlayerSpec addGoalieSpec resetCreatePlayerStateSpec @@ -366,6 +367,12 @@ createGoalieSpec = describe "createGoalie" $ s = createGoalie newProgState in show (s^.progMode) `shouldBe` "CreateGoalie" +editPlayerSpec :: Spec +editPlayerSpec = describe "editPlayer" $ + it "should change the mode appropriately" $ let + s = editPlayer newProgState + in show (s^.progMode) `shouldBe` "EditPlayer" + addPlayerSpec :: Spec addPlayerSpec = describe "addPlayer" $ do let