added create player option to main menu

This commit is contained in:
Jonathan Lamothe 2019-09-09 10:51:32 -04:00
parent 6b73e367e4
commit d5d08aa0f7
5 changed files with 17 additions and 1 deletions

View File

@ -30,6 +30,7 @@ module Mtlstats.Actions
, overtimeCheck , overtimeCheck
, updateGameStats , updateGameStats
, validateGameDate , validateGameDate
, createPlayer
) where ) where
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
@ -111,3 +112,7 @@ validateGameDate s = fromMaybe s $ do
. (gameMonth .~ Nothing) . (gameMonth .~ Nothing)
. (gameDay .~ Nothing) . (gameDay .~ Nothing)
else s else s
-- | Starts player creation mode
createPlayer :: ProgState -> ProgState
createPlayer = progMode .~ CreatePlayer newCreatePlayerState

View File

@ -53,6 +53,7 @@ dispatch s = case s^.progMode of
| null $ gs^.overtimeFlag -> overtimeFlagC | null $ gs^.overtimeFlag -> overtimeFlagC
| not $ gs^.dataVerified -> verifyDataC | not $ gs^.dataVerified -> verifyDataC
| otherwise -> reportC | otherwise -> reportC
CreatePlayer _ -> undefined
mainMenuC :: Controller mainMenuC :: Controller
mainMenuC = Controller mainMenuC = Controller

View File

@ -60,7 +60,9 @@ mainMenu = Menu "*** MAIN MENU ***" True
modify startNewSeason >> return True modify startNewSeason >> return True
, MenuItem '2' "New Game" $ , MenuItem '2' "New Game" $
modify startNewGame >> return True modify startNewGame >> return True
, MenuItem '3' "Exit" $ , MenuItem '3' "Create Player" $
modify createPlayer >> return True
, MenuItem '4' "Exit" $
return False return False
] ]

View File

@ -164,6 +164,7 @@ data ProgMode
= MainMenu = MainMenu
| NewSeason | NewSeason
| NewGame GameState | NewGame GameState
| CreatePlayer CreatePlayerState
deriving (Eq, Show) deriving (Eq, Show)
-- | The game state -- | The game state

View File

@ -39,6 +39,7 @@ spec = describe "Mtlstats.Actions" $ do
overtimeCheckSpec overtimeCheckSpec
updateGameStatsSpec updateGameStatsSpec
validateGameDateSpec validateGameDateSpec
createPlayerSpec
startNewSeasonSpec :: Spec startNewSeasonSpec :: Spec
startNewSeasonSpec = describe "startNewSeason" $ do startNewSeasonSpec = describe "startNewSeason" $ do
@ -315,6 +316,12 @@ validateGameDateSpec = describe "validateGameDate" $ do
s^.progMode.gameStateL.gameMonth `shouldBe` Just 6 s^.progMode.gameStateL.gameMonth `shouldBe` Just 6
s^.progMode.gameStateL.gameDay `shouldBe` Nothing 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 :: IO Player
makePlayer = Player makePlayer = Player
<$> makeNum <$> makeNum