commit
b35136944c
|
@ -5,6 +5,7 @@
|
||||||
- Force expected capitalization on player/goalie names
|
- Force expected capitalization on player/goalie names
|
||||||
- Don't show lifetime totals in report
|
- Don't show lifetime totals in report
|
||||||
- Sort players in YTD and lifetime reports by points
|
- Sort players in YTD and lifetime reports by points
|
||||||
|
- Moved player/goalie creation/editing to edit submenu
|
||||||
|
|
||||||
## 0.8.0
|
## 0.8.0
|
||||||
- Bugfix: removed quotation marks from goalie names in report
|
- Bugfix: removed quotation marks from goalie names in report
|
||||||
|
|
|
@ -30,6 +30,7 @@ module Mtlstats.Actions
|
||||||
, removeChar
|
, removeChar
|
||||||
, createPlayer
|
, createPlayer
|
||||||
, createGoalie
|
, createGoalie
|
||||||
|
, edit
|
||||||
, editPlayer
|
, editPlayer
|
||||||
, editGoalie
|
, editGoalie
|
||||||
, addPlayer
|
, addPlayer
|
||||||
|
@ -82,7 +83,7 @@ removeChar = inputBuffer %~ \case
|
||||||
-- | Starts player creation mode
|
-- | Starts player creation mode
|
||||||
createPlayer :: ProgState -> ProgState
|
createPlayer :: ProgState -> ProgState
|
||||||
createPlayer = let
|
createPlayer = let
|
||||||
callback = modify $ progMode .~ MainMenu
|
callback = modify edit
|
||||||
cps = newCreatePlayerState
|
cps = newCreatePlayerState
|
||||||
& cpsSuccessCallback .~ callback
|
& cpsSuccessCallback .~ callback
|
||||||
& cpsFailureCallback .~ callback
|
& cpsFailureCallback .~ callback
|
||||||
|
@ -91,12 +92,16 @@ createPlayer = let
|
||||||
-- | Starts goalie creation mode
|
-- | Starts goalie creation mode
|
||||||
createGoalie :: ProgState -> ProgState
|
createGoalie :: ProgState -> ProgState
|
||||||
createGoalie = let
|
createGoalie = let
|
||||||
callback = modify $ progMode .~ MainMenu
|
callback = modify edit
|
||||||
cgs = newCreateGoalieState
|
cgs = newCreateGoalieState
|
||||||
& cgsSuccessCallback .~ callback
|
& cgsSuccessCallback .~ callback
|
||||||
& cgsFailureCallback .~ callback
|
& cgsFailureCallback .~ callback
|
||||||
in progMode .~ CreateGoalie cgs
|
in progMode .~ CreateGoalie cgs
|
||||||
|
|
||||||
|
-- | Launches the edit menu
|
||||||
|
edit :: ProgState -> ProgState
|
||||||
|
edit = progMode .~ EditMenu
|
||||||
|
|
||||||
-- | Starts the player editing process
|
-- | Starts the player editing process
|
||||||
editPlayer :: ProgState -> ProgState
|
editPlayer :: ProgState -> ProgState
|
||||||
editPlayer = progMode .~ EditPlayer newEditPlayerState
|
editPlayer = progMode .~ EditPlayer newEditPlayerState
|
||||||
|
|
|
@ -44,6 +44,7 @@ dispatch s = case s^.progMode of
|
||||||
MainMenu -> mainMenuC
|
MainMenu -> mainMenuC
|
||||||
NewSeason -> newSeasonC
|
NewSeason -> newSeasonC
|
||||||
NewGame gs -> newGameC gs
|
NewGame gs -> newGameC gs
|
||||||
|
EditMenu -> editMenuC
|
||||||
CreatePlayer cps
|
CreatePlayer cps
|
||||||
| null $ cps^.cpsNumber -> getPlayerNumC
|
| null $ cps^.cpsNumber -> getPlayerNumC
|
||||||
| null $ cps^.cpsName -> getPlayerNameC
|
| null $ cps^.cpsName -> getPlayerNameC
|
||||||
|
@ -70,6 +71,9 @@ newSeasonC = Controller
|
||||||
return True
|
return True
|
||||||
}
|
}
|
||||||
|
|
||||||
|
editMenuC :: Controller
|
||||||
|
editMenuC = menuController editMenu
|
||||||
|
|
||||||
getPlayerNumC :: Controller
|
getPlayerNumC :: Controller
|
||||||
getPlayerNumC = Controller
|
getPlayerNumC = Controller
|
||||||
{ drawController = drawPrompt playerNumPrompt
|
{ drawController = drawPrompt playerNumPrompt
|
||||||
|
|
|
@ -31,7 +31,8 @@ module Mtlstats.Menu (
|
||||||
newSeasonMenu,
|
newSeasonMenu,
|
||||||
gameMonthMenu,
|
gameMonthMenu,
|
||||||
gameTypeMenu,
|
gameTypeMenu,
|
||||||
gameGoalieMenu
|
gameGoalieMenu,
|
||||||
|
editMenu
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad.IO.Class (liftIO)
|
import Control.Monad.IO.Class (liftIO)
|
||||||
|
@ -113,14 +114,8 @@ 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' "Create Player" $
|
, MenuItem '3' "Edit" $
|
||||||
modify createPlayer >> return True
|
modify edit >> return True
|
||||||
, MenuItem '4' "Create Goalie" $
|
|
||||||
modify createGoalie >> return True
|
|
||||||
, MenuItem '5' "Edit Player" $
|
|
||||||
modify editPlayer >> return True
|
|
||||||
, MenuItem '6' "Edit Goalie" $
|
|
||||||
modify editGoalie >> return True
|
|
||||||
, MenuItem 'X' "Exit" $ do
|
, MenuItem 'X' "Exit" $ do
|
||||||
db <- gets $ view database
|
db <- gets $ view database
|
||||||
liftIO $ do
|
liftIO $ do
|
||||||
|
@ -186,3 +181,18 @@ gameGoalieMenu s = let
|
||||||
(\(ch, (gid, goalie)) -> MenuItem ch (goalieSummary goalie) $
|
(\(ch, (gid, goalie)) -> MenuItem ch (goalieSummary goalie) $
|
||||||
modify $ GI.setGameGoalie gid) $
|
modify $ GI.setGameGoalie gid) $
|
||||||
zip ['1'..] goalies
|
zip ['1'..] goalies
|
||||||
|
|
||||||
|
-- | The edit menu
|
||||||
|
editMenu :: Menu ()
|
||||||
|
editMenu = Menu "*** EDIT ***" ()
|
||||||
|
[ MenuItem '1' "Create Player" $
|
||||||
|
modify createPlayer
|
||||||
|
, MenuItem '2' "Create Goalie" $
|
||||||
|
modify createGoalie
|
||||||
|
, MenuItem '3' "Edit Player" $
|
||||||
|
modify editPlayer
|
||||||
|
, MenuItem '4' "Edit Goalie" $
|
||||||
|
modify editGoalie
|
||||||
|
, MenuItem 'R' "Return to Main Menu" $
|
||||||
|
modify backHome
|
||||||
|
]
|
||||||
|
|
|
@ -26,25 +26,25 @@ module Mtlstats.Menu.EditGoalie
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Control.Monad.Trans.State (modify)
|
import Control.Monad.Trans.State (modify)
|
||||||
import Data.Maybe (maybe)
|
|
||||||
import Lens.Micro ((.~))
|
import Lens.Micro ((.~))
|
||||||
|
|
||||||
|
import Mtlstats.Actions
|
||||||
import Mtlstats.Types
|
import Mtlstats.Types
|
||||||
import Mtlstats.Types.Menu
|
import Mtlstats.Types.Menu
|
||||||
|
|
||||||
-- | The 'Goalie' edit menu
|
-- | The 'Goalie' edit menu
|
||||||
editGoalieMenu :: Menu ()
|
editGoalieMenu :: Menu ()
|
||||||
editGoalieMenu = Menu "*** EDIT GOALTENDER ***" () $ map
|
editGoalieMenu = Menu "*** EDIT GOALTENDER ***" () $ map
|
||||||
(\(key, label, val) -> MenuItem key label $ modify $ maybe
|
(\(ch, label, mode) -> MenuItem ch label $
|
||||||
(progMode .~ MainMenu)
|
modify $ case mode of
|
||||||
(progMode.editGoalieStateL.egsMode .~)
|
Nothing -> edit
|
||||||
val)
|
Just m -> progMode.editGoalieStateL.egsMode .~ m)
|
||||||
-- key, label, value
|
-- key, label, value
|
||||||
[ ( '1', "Edit number", Just EGNumber )
|
[ ( '1', "Edit number", Just EGNumber )
|
||||||
, ( '2', "Edit name", Just EGName )
|
, ( '2', "Edit name", Just EGName )
|
||||||
, ( '3', "Edit YTD stats", Just EGYtd )
|
, ( '3', "Edit YTD stats", Just EGYtd )
|
||||||
, ( '4', "Edit Lifetime stats", Just EGLifetime )
|
, ( '4', "Edit Lifetime stats", Just EGLifetime )
|
||||||
, ( 'R', "Return to Main Menu", Nothing )
|
, ( 'R', "Return to Edit Menu", Nothing )
|
||||||
]
|
]
|
||||||
|
|
||||||
-- | The 'Goalie' YTD edit menu
|
-- | The 'Goalie' YTD edit menu
|
||||||
|
|
|
@ -28,22 +28,24 @@ module Mtlstats.Menu.EditPlayer
|
||||||
import Control.Monad.Trans.State (modify)
|
import Control.Monad.Trans.State (modify)
|
||||||
import Lens.Micro ((.~))
|
import Lens.Micro ((.~))
|
||||||
|
|
||||||
|
import Mtlstats.Actions
|
||||||
import Mtlstats.Types
|
import Mtlstats.Types
|
||||||
import Mtlstats.Types.Menu
|
import Mtlstats.Types.Menu
|
||||||
|
|
||||||
-- | The 'Player' edit menu
|
-- | The 'Player' edit menu
|
||||||
editPlayerMenu :: Menu ()
|
editPlayerMenu :: Menu ()
|
||||||
editPlayerMenu = Menu "*** EDIT PLAYER ***" () $ map
|
editPlayerMenu = Menu "*** EDIT PLAYER ***" () $ map
|
||||||
(\(ch, label, mode) -> MenuItem ch label $ case mode of
|
(\(ch, label, mode) -> MenuItem ch label $
|
||||||
Nothing -> modify $ progMode .~ MainMenu
|
modify $ case mode of
|
||||||
Just m -> modify $ progMode.editPlayerStateL.epsMode .~ m)
|
Nothing -> edit
|
||||||
|
Just m -> progMode.editPlayerStateL.epsMode .~ m)
|
||||||
-- key, label, value
|
-- key, label, value
|
||||||
[ ( '1', "Edit number", Just EPNumber )
|
[ ( '1', "Edit number", Just EPNumber )
|
||||||
, ( '2', "Edit name", Just EPName )
|
, ( '2', "Edit name", Just EPName )
|
||||||
, ( '3', "Edit position", Just EPPosition )
|
, ( '3', "Edit position", Just EPPosition )
|
||||||
, ( '4', "Edit YTD stats", Just EPYtd )
|
, ( '4', "Edit YTD stats", Just EPYtd )
|
||||||
, ( '5', "Edit lifetime stats", Just EPLifetime )
|
, ( '5', "Edit lifetime stats", Just EPLifetime )
|
||||||
, ( 'R', "Finished editing", Nothing )
|
, ( 'R', "Return to Edit Menu", Nothing )
|
||||||
]
|
]
|
||||||
|
|
||||||
-- | The 'Player' YTD stats edit menu
|
-- | The 'Player' YTD stats edit menu
|
||||||
|
|
|
@ -230,6 +230,7 @@ data ProgMode
|
||||||
= MainMenu
|
= MainMenu
|
||||||
| NewSeason
|
| NewSeason
|
||||||
| NewGame GameState
|
| NewGame GameState
|
||||||
|
| EditMenu
|
||||||
| CreatePlayer CreatePlayerState
|
| CreatePlayer CreatePlayerState
|
||||||
| CreateGoalie CreateGoalieState
|
| CreateGoalie CreateGoalieState
|
||||||
| EditPlayer EditPlayerState
|
| EditPlayer EditPlayerState
|
||||||
|
@ -239,6 +240,7 @@ instance Show ProgMode where
|
||||||
show MainMenu = "MainMenu"
|
show MainMenu = "MainMenu"
|
||||||
show NewSeason = "NewSeason"
|
show NewSeason = "NewSeason"
|
||||||
show (NewGame _) = "NewGame"
|
show (NewGame _) = "NewGame"
|
||||||
|
show EditMenu = "EditMenu"
|
||||||
show (CreatePlayer _) = "CreatePlayer"
|
show (CreatePlayer _) = "CreatePlayer"
|
||||||
show (CreateGoalie _) = "CreateGoalie"
|
show (CreateGoalie _) = "CreateGoalie"
|
||||||
show (EditPlayer _) = "EditPlayer"
|
show (EditPlayer _) = "EditPlayer"
|
||||||
|
|
|
@ -52,6 +52,7 @@ spec = describe "Mtlstats.Actions" $ do
|
||||||
removeCharSpec
|
removeCharSpec
|
||||||
createPlayerSpec
|
createPlayerSpec
|
||||||
createGoalieSpec
|
createGoalieSpec
|
||||||
|
editSpec
|
||||||
editPlayerSpec
|
editPlayerSpec
|
||||||
editGoalieSpec
|
editGoalieSpec
|
||||||
addPlayerSpec
|
addPlayerSpec
|
||||||
|
@ -198,6 +199,12 @@ createGoalieSpec = describe "createGoalie" $
|
||||||
s = createGoalie newProgState
|
s = createGoalie newProgState
|
||||||
in show (s^.progMode) `shouldBe` "CreateGoalie"
|
in show (s^.progMode) `shouldBe` "CreateGoalie"
|
||||||
|
|
||||||
|
editSpec :: Spec
|
||||||
|
editSpec = describe "edit" $
|
||||||
|
it "should change the mode to EditMenu" $ let
|
||||||
|
ps = edit newProgState
|
||||||
|
in show (ps^.progMode) `shouldBe` "EditMenu"
|
||||||
|
|
||||||
editPlayerSpec :: Spec
|
editPlayerSpec :: Spec
|
||||||
editPlayerSpec = describe "editPlayer" $
|
editPlayerSpec = describe "editPlayer" $
|
||||||
it "should change the mode appropriately" $ let
|
it "should change the mode appropriately" $ let
|
||||||
|
|
Loading…
Reference in New Issue
Block a user