added create player option to main menu
This commit is contained in:
parent
6b73e367e4
commit
d5d08aa0f7
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
]
|
||||
|
||||
|
|
|
@ -164,6 +164,7 @@ data ProgMode
|
|||
= MainMenu
|
||||
| NewSeason
|
||||
| NewGame GameState
|
||||
| CreatePlayer CreatePlayerState
|
||||
deriving (Eq, Show)
|
||||
|
||||
-- | The game state
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user