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