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