added "Edit Player" to main menu
This commit is contained in:
parent
cb4fc77dd6
commit
5fd67f3802
|
@ -32,6 +32,7 @@ module Mtlstats.Actions
|
|||
, validateGameDate
|
||||
, createPlayer
|
||||
, createGoalie
|
||||
, editPlayer
|
||||
, addPlayer
|
||||
, addGoalie
|
||||
, resetCreatePlayerState
|
||||
|
@ -159,6 +160,10 @@ createGoalie = let
|
|||
& cgsFailureCallback .~ callback
|
||||
in progMode .~ CreateGoalie cgs
|
||||
|
||||
-- | Starts the player editing process
|
||||
editPlayer :: ProgState -> ProgState
|
||||
editPlayer = progMode .~ EditPlayer newEditPlayerState
|
||||
|
||||
-- | Adds the entered player to the roster
|
||||
addPlayer :: ProgState -> ProgState
|
||||
addPlayer s = fromMaybe s $ do
|
||||
|
|
|
@ -73,7 +73,9 @@ mainMenu = Menu "*** MAIN MENU ***" True
|
|||
modify createPlayer >> return True
|
||||
, MenuItem '4' "Create Goalie" $
|
||||
modify createGoalie >> return True
|
||||
, MenuItem '5' "Exit" $ do
|
||||
, MenuItem '5' "Edit Player" $
|
||||
modify editPlayer >> return True
|
||||
, MenuItem '6' "Exit" $ do
|
||||
db <- gets $ view database
|
||||
liftIO $ do
|
||||
dir <- getAppUserDataDirectory appName
|
||||
|
|
|
@ -221,6 +221,7 @@ instance Show ProgMode where
|
|||
show (NewGame _) = "NewGame"
|
||||
show (CreatePlayer _) = "CreatePlayer"
|
||||
show (CreateGoalie _) = "CreateGoalie"
|
||||
show (EditPlayer _) = "EditPlayer"
|
||||
|
||||
-- | The game state
|
||||
data GameState = GameState
|
||||
|
|
|
@ -57,6 +57,7 @@ spec = describe "Mtlstats.Actions" $ do
|
|||
validateGameDateSpec
|
||||
createPlayerSpec
|
||||
createGoalieSpec
|
||||
editPlayerSpec
|
||||
addPlayerSpec
|
||||
addGoalieSpec
|
||||
resetCreatePlayerStateSpec
|
||||
|
@ -366,6 +367,12 @@ createGoalieSpec = describe "createGoalie" $
|
|||
s = createGoalie newProgState
|
||||
in show (s^.progMode) `shouldBe` "CreateGoalie"
|
||||
|
||||
editPlayerSpec :: Spec
|
||||
editPlayerSpec = describe "editPlayer" $
|
||||
it "should change the mode appropriately" $ let
|
||||
s = editPlayer newProgState
|
||||
in show (s^.progMode) `shouldBe` "EditPlayer"
|
||||
|
||||
addPlayerSpec :: Spec
|
||||
addPlayerSpec = describe "addPlayer" $ do
|
||||
let
|
||||
|
|
Loading…
Reference in New Issue
Block a user