added goalie creation to main menu
This commit is contained in:
parent
e94bf59c81
commit
67bb12920c
|
@ -31,6 +31,7 @@ module Mtlstats.Actions
|
|||
, updateGameStats
|
||||
, validateGameDate
|
||||
, createPlayer
|
||||
, createGoalie
|
||||
, addPlayer
|
||||
, recordGoalAssists
|
||||
, awardGoal
|
||||
|
@ -139,13 +140,21 @@ validateGameDate s = fromMaybe s $ do
|
|||
-- | Starts player creation mode
|
||||
createPlayer :: ProgState -> ProgState
|
||||
createPlayer = let
|
||||
cb = modify $ progMode .~ MainMenu
|
||||
cps
|
||||
= newCreatePlayerState
|
||||
& cpsSuccessCallback .~ cb
|
||||
& cpsFailureCallback .~ cb
|
||||
callback = modify $ progMode .~ MainMenu
|
||||
cps = newCreatePlayerState
|
||||
& cpsSuccessCallback .~ callback
|
||||
& cpsFailureCallback .~ callback
|
||||
in progMode .~ CreatePlayer cps
|
||||
|
||||
-- | Starts goalie creation mode
|
||||
createGoalie :: ProgState -> ProgState
|
||||
createGoalie = let
|
||||
callback = modify $ progMode .~ MainMenu
|
||||
cgs = newCreateGoalieState
|
||||
& cgsSuccessCallback .~ callback
|
||||
& cgsFailureCallback .~ callback
|
||||
in progMode .~ CreateGoalie cgs
|
||||
|
||||
-- | Adds the entered player to the roster
|
||||
addPlayer :: ProgState -> ProgState
|
||||
addPlayer s = fromMaybe s $ do
|
||||
|
|
|
@ -71,7 +71,9 @@ mainMenu = Menu "*** MAIN MENU ***" True
|
|||
modify startNewGame >> return True
|
||||
, MenuItem '3' "Create Player" $
|
||||
modify createPlayer >> return True
|
||||
, MenuItem '4' "Exit" $ do
|
||||
, MenuItem '4' "Create Goalie" $
|
||||
modify createGoalie >> return True
|
||||
, MenuItem '5' "Exit" $ do
|
||||
db <- gets $ view database
|
||||
liftIO $ do
|
||||
dir <- getAppUserDataDirectory appName
|
||||
|
|
|
@ -54,6 +54,7 @@ spec = describe "Mtlstats.Actions" $ do
|
|||
updateGameStatsSpec
|
||||
validateGameDateSpec
|
||||
createPlayerSpec
|
||||
createGoalieSpec
|
||||
addPlayerSpec
|
||||
recordGoalAssistsSpec
|
||||
awardGoalSpec
|
||||
|
@ -353,6 +354,12 @@ createPlayerSpec = describe "createPlayer" $
|
|||
s = createPlayer newProgState
|
||||
in show (s^.progMode) `shouldBe` "CreatePlayer"
|
||||
|
||||
createGoalieSpec :: Spec
|
||||
createGoalieSpec = describe "createGoalie" $
|
||||
it "should change the mode appropriately" $ let
|
||||
s = createGoalie newProgState
|
||||
in show (s^.progMode) `shouldBe` "CreateGoalie"
|
||||
|
||||
addPlayerSpec :: Spec
|
||||
addPlayerSpec = describe "addPlayer" $ do
|
||||
let
|
||||
|
|
Loading…
Reference in New Issue
Block a user