diff --git a/src/Mtlstats/Actions.hs b/src/Mtlstats/Actions.hs index 460e3fd..c20e2da 100644 --- a/src/Mtlstats/Actions.hs +++ b/src/Mtlstats/Actions.hs @@ -30,6 +30,7 @@ module Mtlstats.Actions , overtimeCheck , updateGameStats , validateGameDate + , createPlayer ) where import Data.Maybe (fromMaybe) @@ -111,3 +112,7 @@ validateGameDate s = fromMaybe s $ do . (gameMonth .~ Nothing) . (gameDay .~ Nothing) else s + +-- | Starts player creation mode +createPlayer :: ProgState -> ProgState +createPlayer = progMode .~ CreatePlayer newCreatePlayerState diff --git a/src/Mtlstats/Control.hs b/src/Mtlstats/Control.hs index 02efaee..01331ad 100644 --- a/src/Mtlstats/Control.hs +++ b/src/Mtlstats/Control.hs @@ -53,6 +53,7 @@ dispatch s = case s^.progMode of | null $ gs^.overtimeFlag -> overtimeFlagC | not $ gs^.dataVerified -> verifyDataC | otherwise -> reportC + CreatePlayer _ -> undefined mainMenuC :: Controller mainMenuC = Controller diff --git a/src/Mtlstats/Menu.hs b/src/Mtlstats/Menu.hs index 42a2e7f..ba2c640 100644 --- a/src/Mtlstats/Menu.hs +++ b/src/Mtlstats/Menu.hs @@ -60,7 +60,9 @@ mainMenu = Menu "*** MAIN MENU ***" True modify startNewSeason >> return True , MenuItem '2' "New Game" $ modify startNewGame >> return True - , MenuItem '3' "Exit" $ + , MenuItem '3' "Create Player" $ + modify createPlayer >> return True + , MenuItem '4' "Exit" $ return False ] diff --git a/src/Mtlstats/Types.hs b/src/Mtlstats/Types.hs index 4375bf6..b5a0324 100644 --- a/src/Mtlstats/Types.hs +++ b/src/Mtlstats/Types.hs @@ -164,6 +164,7 @@ data ProgMode = MainMenu | NewSeason | NewGame GameState + | CreatePlayer CreatePlayerState deriving (Eq, Show) -- | The game state diff --git a/test/ActionsSpec.hs b/test/ActionsSpec.hs index c023cbb..3af72f5 100644 --- a/test/ActionsSpec.hs +++ b/test/ActionsSpec.hs @@ -39,6 +39,7 @@ spec = describe "Mtlstats.Actions" $ do overtimeCheckSpec updateGameStatsSpec validateGameDateSpec + createPlayerSpec startNewSeasonSpec :: Spec startNewSeasonSpec = describe "startNewSeason" $ do @@ -315,6 +316,12 @@ validateGameDateSpec = describe "validateGameDate" $ do s^.progMode.gameStateL.gameMonth `shouldBe` Just 6 s^.progMode.gameStateL.gameDay `shouldBe` Nothing +createPlayerSpec :: Spec +createPlayerSpec = describe "createPlayer" $ + it "should change the mode appropriately" $ let + s = createPlayer newProgState + in s^.progMode `shouldBe` CreatePlayer newCreatePlayerState + makePlayer :: IO Player makePlayer = Player <$> makeNum