logic branch for database saving on new season

This commit is contained in:
Jonathan Lamothe 2020-01-14 02:42:30 -05:00
parent 3b4ce50ae8
commit 2bf8d15bd4
4 changed files with 18 additions and 14 deletions

View File

@ -54,7 +54,9 @@ import Mtlstats.Util
-- | Starts a new season
startNewSeason :: ProgState -> ProgState
startNewSeason = (progMode .~ NewSeason) . (database . dbGames .~ 0)
startNewSeason
= (progMode .~ NewSeason False)
. (database.dbGames .~ 0)
-- | Resets all players year-to-date stats
resetYtd :: ProgState -> ProgState

View File

@ -42,7 +42,7 @@ import Mtlstats.Types
dispatch :: ProgState -> Controller
dispatch s = case s^.progMode of
MainMenu -> mainMenuC
NewSeason -> newSeasonC
NewSeason flag -> newSeasonC flag
NewGame gs -> newGameC gs
EditMenu -> editMenuC
CreatePlayer cps
@ -63,13 +63,9 @@ mainMenuC = Controller
, handleController = menuHandler mainMenu
}
newSeasonC :: Controller
newSeasonC = Controller
{ drawController = const $ drawMenu newSeasonMenu
, handleController = \e -> do
menuHandler newSeasonMenu e
return True
}
newSeasonC :: Bool -> Controller
newSeasonC False = promptController newSeasonPrompt
newSeasonC True = menuController newSeasonMenu
editMenuC :: Controller
editMenuC = menuController editMenu

View File

@ -34,6 +34,7 @@ module Mtlstats.Prompt (
numPromptWithFallback,
selectPrompt,
-- * Individual prompts
newSeasonPrompt,
playerNumPrompt,
playerNamePrompt,
playerPosPrompt,
@ -167,6 +168,11 @@ numPromptWithFallback pStr fallback act = Prompt
, promptSpecialKey = const $ return ()
}
-- | Prompts the user for a filename to save a backup of the database
-- to
newSeasonPrompt :: Prompt
newSeasonPrompt = undefined
-- | Builds a selection prompt
selectPrompt :: SelectParams a -> Prompt
selectPrompt params = Prompt

View File

@ -232,7 +232,7 @@ data ProgState = ProgState
-- | The program mode
data ProgMode
= MainMenu
| NewSeason
| NewSeason Bool
| NewGame GameState
| EditMenu
| CreatePlayer CreatePlayerState
@ -242,7 +242,7 @@ data ProgMode
instance Show ProgMode where
show MainMenu = "MainMenu"
show NewSeason = "NewSeason"
show (NewSeason _) = "NewSeason"
show (NewGame _) = "NewGame"
show EditMenu = "EditMenu"
show (CreatePlayer _) = "CreatePlayer"