From 9a179ed166f7200fff496be41f7a773b2fde6334 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Sat, 9 Nov 2019 01:50:29 -0500 Subject: [PATCH] added EditGoalieState and EditGoalieMode types --- src/Mtlstats/Control.hs | 2 ++ src/Mtlstats/Control/EditGoalie.hs | 28 ++++++++++++++++++++ src/Mtlstats/Types.hs | 42 ++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 src/Mtlstats/Control/EditGoalie.hs diff --git a/src/Mtlstats/Control.hs b/src/Mtlstats/Control.hs index 4e870ac..e57b4b4 100644 --- a/src/Mtlstats/Control.hs +++ b/src/Mtlstats/Control.hs @@ -29,6 +29,7 @@ import Lens.Micro.Extras (view) import qualified UI.NCurses as C import Mtlstats.Actions +import Mtlstats.Control.EditGoalie import Mtlstats.Control.EditPlayer import Mtlstats.Control.NewGame import Mtlstats.Handlers @@ -53,6 +54,7 @@ dispatch s = case s^.progMode of | null $ cgs^.cgsName -> getGoalieNameC | otherwise -> confirmCreateGoalieC EditPlayer eps -> editPlayerC eps + EditGoalie egs -> editGoalieC egs mainMenuC :: Controller mainMenuC = Controller diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs new file mode 100644 index 0000000..cfb980a --- /dev/null +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -0,0 +1,28 @@ +{- | + +mtlstats +Copyright (C) 2019 Rhéal Lamothe + + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or (at +your option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +-} + +module Mtlstats.Control.EditGoalie (editGoalieC) where + +import Mtlstats.Types + +-- | Controller/dispatcher for editing a 'Goalie' +editGoalieC :: EditGoalieState -> Controller +editGoalieC = undefined diff --git a/src/Mtlstats/Types.hs b/src/Mtlstats/Types.hs index df2908d..cc548bf 100644 --- a/src/Mtlstats/Types.hs +++ b/src/Mtlstats/Types.hs @@ -33,6 +33,8 @@ module Mtlstats.Types ( CreateGoalieState (..), EditPlayerState (..), EditPlayerMode (..), + EditGoalieState (..), + EditGoalieMode (..), Database (..), Player (..), PlayerStats (..), @@ -89,6 +91,9 @@ module Mtlstats.Types ( -- ** EditPlayerState Lenses epsSelectedPlayer, epsMode, + -- ** EditGoalieState Lenses + egsSelectedGoalie, + egsMode, -- ** Database Lenses dbPlayers, dbGoalies, @@ -129,6 +134,7 @@ module Mtlstats.Types ( newCreatePlayerState, newCreateGoalieState, newEditPlayerState, + newEditGoalieState, newDatabase, newPlayer, newPlayerStats, @@ -218,6 +224,7 @@ data ProgMode | CreatePlayer CreatePlayerState | CreateGoalie CreateGoalieState | EditPlayer EditPlayerState + | EditGoalie EditGoalieState instance Show ProgMode where show MainMenu = "MainMenu" @@ -226,6 +233,7 @@ instance Show ProgMode where show (CreatePlayer _) = "CreatePlayer" show (CreateGoalie _) = "CreateGoalie" show (EditPlayer _) = "EditPlayer" + show (EditGoalie _) = "EditGoalie" -- | The game state data GameState = GameState @@ -334,6 +342,32 @@ data EditPlayerMode | EPLtPMin deriving (Eq, Show) +-- | 'Goalie' edit status +data EditGoalieState = EditGoalieState + { _egsSelectedGoalie :: Maybe Int + -- ^ The index number of the 'Goalie' being edited + , _egsMode :: EditGoalieMode + } + +-- | 'Goalie' editing mode +data EditGoalieMode + = EGMenu + | EGNumber + | EGName + | EGYtdGames + | EGYtdMins + | EGYtdGoals + | EGYtdWins + | EGYtdLosses + | EGYtdTies + | EGLtGames + | EGLtMins + | EGLtGoals + | EGLtWins + | EGLtLosses + | EGLtTies + deriving (Eq, Show) + -- | Represents the database data Database = Database { _dbPlayers :: [Player] @@ -581,6 +615,7 @@ makeLenses ''GameState makeLenses ''CreatePlayerState makeLenses ''CreateGoalieState makeLenses ''EditPlayerState +makeLenses ''EditGoalieState makeLenses ''Database makeLenses ''Player makeLenses ''PlayerStats @@ -678,6 +713,13 @@ newEditPlayerState = EditPlayerState , _epsMode = EPMenu } +-- | Constructor for an 'EditGoalieState' value +newEditGoalieState :: EditGoalieState +newEditGoalieState = EditGoalieState + { _egsSelectedGoalie = Nothing + , _egsMode = EGMenu + } + -- | Constructor for a 'Database' newDatabase :: Database newDatabase = Database