refactored handleEvent and draw

This commit is contained in:
Jonathan Lamothe 2019-08-23 10:04:33 -04:00
parent a3ccb47128
commit 2c77053bbe
2 changed files with 12 additions and 11 deletions

View File

@ -19,6 +19,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
-}
{-# LANGUAGE LambdaCase #-}
module Mtlstats.Events (handleEvent) where
import Control.Monad.Trans.State (gets, modify)
@ -35,11 +37,10 @@ handleEvent
:: C.Event
-- ^ The event being handled
-> Action Bool
handleEvent e = do
m <- gets $ view progMode
case m of
handleEvent e = gets (view progMode) >>= \case
MainMenu -> menuHandler mainMenu e
NewSeason -> menuHandler newSeasonMenu e >> return True
NewGame gs -> if null $ gs ^. gameType
then menuHandler gameTypeMenu e >> return True
else undefined
NewGame gs
| null $ gs ^. gameType ->
menuHandler gameTypeMenu e >> return True
| otherwise -> undefined

View File

@ -36,7 +36,7 @@ draw s = do
case s ^. progMode of
MainMenu -> drawMenu mainMenu
NewSeason -> drawMenu newSeasonMenu
NewGame gs -> if null $ gs ^. gameType
then drawMenu gameTypeMenu
else undefined
NewGame gs
| null $ gs ^. gameType -> drawMenu gameTypeMenu
| otherwise ->undefined
C.render