From 9a179ed166f7200fff496be41f7a773b2fde6334 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Sat, 9 Nov 2019 01:50:29 -0500 Subject: [PATCH 01/61] 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 From dde0291321f6b1601f660758f4b1f408b9145aa4 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Sat, 9 Nov 2019 02:01:44 -0500 Subject: [PATCH 02/61] implemented editGoalieC --- src/Mtlstats/Control/EditGoalie.hs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index cfb980a..49938cd 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -21,8 +21,18 @@ along with this program. If not, see . module Mtlstats.Control.EditGoalie (editGoalieC) where +import Lens.Micro ((^.)) + import Mtlstats.Types -- | Controller/dispatcher for editing a 'Goalie' editGoalieC :: EditGoalieState -> Controller -editGoalieC = undefined +editGoalieC egs + | null $ egs^.egsSelectedGoalie = selectC + | otherwise = editC + +selectC :: Controller +selectC = undefined + +editC :: Controller +editC = undefined From cadbd6354bb433acd4a180dcc58954a90d2dd52c Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Sat, 9 Nov 2019 02:05:51 -0500 Subject: [PATCH 03/61] implemented Mtlstats.Control.EditGoalie.selectC --- src/Mtlstats/Control/EditGoalie.hs | 4 +++- src/Mtlstats/Prompt/EditGoalie.hs | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/Mtlstats/Prompt/EditGoalie.hs diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index 49938cd..52815b3 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -23,6 +23,8 @@ module Mtlstats.Control.EditGoalie (editGoalieC) where import Lens.Micro ((^.)) +import Mtlstats.Prompt +import Mtlstats.Prompt.EditGoalie import Mtlstats.Types -- | Controller/dispatcher for editing a 'Goalie' @@ -32,7 +34,7 @@ editGoalieC egs | otherwise = editC selectC :: Controller -selectC = undefined +selectC = promptController goalieToEditPrompt editC :: Controller editC = undefined diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs new file mode 100644 index 0000000..d80041f --- /dev/null +++ b/src/Mtlstats/Prompt/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.Prompt.EditGoalie (goalieToEditPrompt) where + +import Mtlstats.Types + +-- | Prompt to select a 'Goalie' for editing +goalieToEditPrompt :: Prompt +goalieToEditPrompt = undefined From 8aa8d39f705ba800379a940648f6ef93d771ddb3 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Mon, 11 Nov 2019 15:30:04 -0500 Subject: [PATCH 04/61] implemented goalieToEditPrompt --- src/Mtlstats/Prompt/EditGoalie.hs | 7 ++++++- src/Mtlstats/Types.hs | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index d80041f..99f9c26 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -21,8 +21,13 @@ along with this program. If not, see . module Mtlstats.Prompt.EditGoalie (goalieToEditPrompt) where +import Control.Monad.Trans.State (modify) +import Lens.Micro ((.~)) + +import Mtlstats.Prompt import Mtlstats.Types -- | Prompt to select a 'Goalie' for editing goalieToEditPrompt :: Prompt -goalieToEditPrompt = undefined +goalieToEditPrompt = selectGoaliePrompt "Goalie to edit: " $ + modify . (progMode.editGoalieStateL.egsSelectedGoalie .~) diff --git a/src/Mtlstats/Types.hs b/src/Mtlstats/Types.hs index cc548bf..6e1c3a9 100644 --- a/src/Mtlstats/Types.hs +++ b/src/Mtlstats/Types.hs @@ -54,6 +54,7 @@ module Mtlstats.Types ( createPlayerStateL, createGoalieStateL, editPlayerStateL, + editGoalieStateL, -- ** GameState Lenses gameYear, gameMonth, @@ -651,6 +652,9 @@ editPlayerStateL = lens _ -> newEditPlayerState) (\_ eps -> EditPlayer eps) +editGoalieStateL :: Lens' ProgMode EditGoalieState +editGoalieStateL = undefined + -- | Constructor for a 'ProgState' newProgState :: ProgState newProgState = ProgState From f9849023bc5d723ef96edf7ab0389403e9a52c1a Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Mon, 11 Nov 2019 20:00:41 -0500 Subject: [PATCH 05/61] implemented editGoalieStateL --- src/Mtlstats/Types.hs | 6 +++++- test/TypesSpec.hs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Types.hs b/src/Mtlstats/Types.hs index 6e1c3a9..c150902 100644 --- a/src/Mtlstats/Types.hs +++ b/src/Mtlstats/Types.hs @@ -653,7 +653,11 @@ editPlayerStateL = lens (\_ eps -> EditPlayer eps) editGoalieStateL :: Lens' ProgMode EditGoalieState -editGoalieStateL = undefined +editGoalieStateL = lens + (\case + EditGoalie egs -> egs + _ -> newEditGoalieState) + (\_ egs -> EditGoalie egs) -- | Constructor for a 'ProgState' newProgState :: ProgState diff --git a/test/TypesSpec.hs b/test/TypesSpec.hs index e3527f9..06b8e2d 100644 --- a/test/TypesSpec.hs +++ b/test/TypesSpec.hs @@ -56,6 +56,7 @@ spec = describe "Mtlstats.Types" $ do createPlayerStateLSpec createGoalieStateLSpec editPlayerStateLSpec + editGoalieStateLSpec teamScoreSpec otherScoreSpec homeTeamSpec @@ -169,6 +170,24 @@ editPlayerStateLSpec = describe "editPlayerStateL" $ eps2 = newEditPlayerState & epsSelectedPlayer ?~ 2 +editGoalieStateLSpec :: Spec +editGoalieStateLSpec = describe "editGoalieStateL" $ + lensSpec editGoalieStateL + -- getters + [ ( "missing state", MainMenu, newEditGoalieState ) + , ( "with state", EditGoalie egs1, egs1 ) + ] + -- setters + [ ( "set state", MainMenu, egs1 ) + , ( "change state", EditGoalie egs1, egs2 ) + , ( "clear state", EditGoalie egs1, newEditGoalieState ) + ] + where + egs1 = newEditGoalieState + & egsSelectedGoalie ?~ 1 + egs2 = newEditGoalieState + & egsSelectedGoalie ?~ 2 + teamScoreSpec :: Spec teamScoreSpec = describe "teamScore" $ do let @@ -858,6 +877,17 @@ instance Comparable EditPlayerState where it ("should be " ++ show (expected^.epsMode)) $ actual^.epsMode `shouldBe` expected^.epsMode +instance Comparable EditGoalieState where + compareTest actual expected = do + + describe "egsSelectedGoalie" $ + it ("should be " ++ show (expected^.egsSelectedGoalie)) $ + actual^.egsSelectedGoalie `shouldBe` expected^.egsSelectedGoalie + + describe "egsMode" $ + it ("should be " ++ show (expected^.egsMode)) $ + actual^.egsMode `shouldBe` expected^.egsMode + instance Comparable CreateGoalieState where compareTest actual expected = do From 3dfbfe7090a5d47eb88b8fb48f41889e6bd2d333 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Mon, 11 Nov 2019 20:38:20 -0500 Subject: [PATCH 06/61] implemented Mtlstats.Control.EditGoalie.editC --- src/Mtlstats/Control/EditGoalie.hs | 68 ++++++++++++++++++++++++++++-- src/Mtlstats/Menu.hs | 5 +++ 2 files changed, 70 insertions(+), 3 deletions(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index 52815b3..aecd0db 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -19,6 +19,8 @@ along with this program. If not, see . -} +{-# LANGUAGE LambdaCase #-} + module Mtlstats.Control.EditGoalie (editGoalieC) where import Lens.Micro ((^.)) @@ -31,10 +33,70 @@ import Mtlstats.Types editGoalieC :: EditGoalieState -> Controller editGoalieC egs | null $ egs^.egsSelectedGoalie = selectC - | otherwise = editC + | otherwise = editC $ egs^.egsMode selectC :: Controller selectC = promptController goalieToEditPrompt -editC :: Controller -editC = undefined +editC :: EditGoalieMode -> Controller +editC = \case + EGMenu -> menuC + EGNumber -> numberC + EGName -> nameC + EGYtdGames -> ytdGamesC + EGYtdMins -> ytdMinsC + EGYtdGoals -> ytdGoalsC + EGYtdWins -> ytdWinsC + EGYtdLosses -> ytdLossesC + EGYtdTies -> ytdTiesC + EGLtGames -> ltGamesC + EGLtMins -> ltMinsC + EGLtGoals -> ltGoalsC + EGLtWins -> ltWinsC + EGLtLosses -> ltLossesC + EGLtTies -> ltTiesC + +menuC :: Controller +menuC = undefined + +numberC :: Controller +numberC = undefined + +nameC :: Controller +nameC = undefined + +ytdGamesC :: Controller +ytdGamesC = undefined + +ytdMinsC :: Controller +ytdMinsC = undefined + +ytdGoalsC :: Controller +ytdGoalsC = undefined + +ytdWinsC :: Controller +ytdWinsC = undefined + +ytdLossesC :: Controller +ytdLossesC = undefined + +ytdTiesC :: Controller +ytdTiesC = undefined + +ltGamesC :: Controller +ltGamesC = undefined + +ltMinsC :: Controller +ltMinsC = undefined + +ltGoalsC :: Controller +ltGoalsC = undefined + +ltWinsC :: Controller +ltWinsC = undefined + +ltLossesC :: Controller +ltLossesC = undefined + +ltTiesC :: Controller +ltTiesC = undefined diff --git a/src/Mtlstats/Menu.hs b/src/Mtlstats/Menu.hs index 1ba882e..6112cd3 100644 --- a/src/Mtlstats/Menu.hs +++ b/src/Mtlstats/Menu.hs @@ -30,6 +30,7 @@ module Mtlstats.Menu ( gameMonthMenu, gameTypeMenu, editPlayerMenu, + editGoalieMenu, gameGoalieMenu ) where @@ -158,6 +159,10 @@ editPlayerMenu = Menu "*** EDIT PLAYER ***" () $ map , ( '0', "Finished editing", Nothing ) ] +-- | The 'Goalie' edit menu +editGoalieMenu :: Menu () +editGoalieMenu = undefined + -- | Game goalie selection menu gameGoalieMenu :: ProgState -> Menu () gameGoalieMenu s = let From e1f92ce92eb18541437d6bd9902a25607a86f43a Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Mon, 11 Nov 2019 20:47:50 -0500 Subject: [PATCH 07/61] implemented Mtlstats.Control.EditGoalie.menuC --- src/Mtlstats/Control/EditGoalie.hs | 7 ++++++- src/Mtlstats/Menu.hs | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index aecd0db..59a872f 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -24,7 +24,9 @@ along with this program. If not, see . module Mtlstats.Control.EditGoalie (editGoalieC) where import Lens.Micro ((^.)) +import UI.NCurses as C +import Mtlstats.Menu import Mtlstats.Prompt import Mtlstats.Prompt.EditGoalie import Mtlstats.Types @@ -57,7 +59,7 @@ editC = \case EGLtTies -> ltTiesC menuC :: Controller -menuC = undefined +menuC = menuControllerWith header editGoalieMenu numberC :: Controller numberC = undefined @@ -100,3 +102,6 @@ ltLossesC = undefined ltTiesC :: Controller ltTiesC = undefined + +header :: ProgState -> C.Update () +header = undefined diff --git a/src/Mtlstats/Menu.hs b/src/Mtlstats/Menu.hs index 6112cd3..1d586c3 100644 --- a/src/Mtlstats/Menu.hs +++ b/src/Mtlstats/Menu.hs @@ -22,6 +22,7 @@ along with this program. If not, see . module Mtlstats.Menu ( -- * Menu Functions menuController, + menuControllerWith, drawMenu, menuHandler, -- * Menus @@ -65,6 +66,16 @@ menuController menu = Controller return True } +-- | Generate a simple 'Controller' for a 'Menu' with a header +menuControllerWith + :: (ProgState -> C.Update ()) + -- ^ Generates the header + -> Menu () + -- ^ The menu + -> Controller + -- ^ The resulting controller +menuControllerWith = undefined + -- | The draw function for a 'Menu' drawMenu :: Menu a -> C.Update C.CursorMode drawMenu m = do From d14abdb248794bb7e0dd5ace90dcbe0d294401ae Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Mon, 11 Nov 2019 20:52:56 -0500 Subject: [PATCH 08/61] implemented menuControllerWith --- src/Mtlstats/Menu.hs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Mtlstats/Menu.hs b/src/Mtlstats/Menu.hs index 1d586c3..b812ae2 100644 --- a/src/Mtlstats/Menu.hs +++ b/src/Mtlstats/Menu.hs @@ -59,12 +59,7 @@ import Mtlstats.Util -- | Generates a simple 'Controller' for a Menu menuController :: Menu () -> Controller -menuController menu = Controller - { drawController = const $ drawMenu menu - , handleController = \e -> do - menuHandler menu e - return True - } +menuController = menuControllerWith $ const $ return () -- | Generate a simple 'Controller' for a 'Menu' with a header menuControllerWith @@ -74,7 +69,14 @@ menuControllerWith -- ^ The menu -> Controller -- ^ The resulting controller -menuControllerWith = undefined +menuControllerWith header menu = Controller + { drawController = \s -> do + header s + drawMenu menu + , handleController = \e -> do + menuHandler menu e + return True + } -- | The draw function for a 'Menu' drawMenu :: Menu a -> C.Update C.CursorMode From f1f0ffef99b041cfa856d5f3984781156996e0e5 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Mon, 11 Nov 2019 22:03:23 -0500 Subject: [PATCH 09/61] added control branches for goalie YTD and lifetime edit menus --- src/Mtlstats/Control/EditGoalie.hs | 8 ++++++++ src/Mtlstats/Types.hs | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index 59a872f..97e538e 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -45,6 +45,8 @@ editC = \case EGMenu -> menuC EGNumber -> numberC EGName -> nameC + EGYtd -> ytdMenuC + EGLifetime -> lifetimeMenuC EGYtdGames -> ytdGamesC EGYtdMins -> ytdMinsC EGYtdGoals -> ytdGoalsC @@ -67,6 +69,12 @@ numberC = undefined nameC :: Controller nameC = undefined +ytdMenuC :: Controller +ytdMenuC = undefined + +lifetimeMenuC :: Controller +lifetimeMenuC = undefined + ytdGamesC :: Controller ytdGamesC = undefined diff --git a/src/Mtlstats/Types.hs b/src/Mtlstats/Types.hs index c150902..5174aca 100644 --- a/src/Mtlstats/Types.hs +++ b/src/Mtlstats/Types.hs @@ -355,6 +355,8 @@ data EditGoalieMode = EGMenu | EGNumber | EGName + | EGYtd + | EGLifetime | EGYtdGames | EGYtdMins | EGYtdGoals From 3c9b7dd9897cb050043175f814d16001d9f1cbe6 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Tue, 12 Nov 2019 09:48:15 -0500 Subject: [PATCH 10/61] broke Mtlstats.Menu.EditGoalie module off from Mtlstats.Menu --- src/Mtlstats/Control/EditGoalie.hs | 1 + src/Mtlstats/Menu.hs | 5 ---- src/Mtlstats/Menu/EditGoalie.hs | 44 ++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 src/Mtlstats/Menu/EditGoalie.hs diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index 97e538e..12f2fa6 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -27,6 +27,7 @@ import Lens.Micro ((^.)) import UI.NCurses as C import Mtlstats.Menu +import Mtlstats.Menu.EditGoalie import Mtlstats.Prompt import Mtlstats.Prompt.EditGoalie import Mtlstats.Types diff --git a/src/Mtlstats/Menu.hs b/src/Mtlstats/Menu.hs index b812ae2..4967b2a 100644 --- a/src/Mtlstats/Menu.hs +++ b/src/Mtlstats/Menu.hs @@ -31,7 +31,6 @@ module Mtlstats.Menu ( gameMonthMenu, gameTypeMenu, editPlayerMenu, - editGoalieMenu, gameGoalieMenu ) where @@ -172,10 +171,6 @@ editPlayerMenu = Menu "*** EDIT PLAYER ***" () $ map , ( '0', "Finished editing", Nothing ) ] --- | The 'Goalie' edit menu -editGoalieMenu :: Menu () -editGoalieMenu = undefined - -- | Game goalie selection menu gameGoalieMenu :: ProgState -> Menu () gameGoalieMenu s = let diff --git a/src/Mtlstats/Menu/EditGoalie.hs b/src/Mtlstats/Menu/EditGoalie.hs new file mode 100644 index 0000000..d685255 --- /dev/null +++ b/src/Mtlstats/Menu/EditGoalie.hs @@ -0,0 +1,44 @@ +{- | + +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.Menu.EditGoalie (editGoalieMenu) where + +import Control.Monad.Trans.State (modify) +import Data.Maybe (maybe) +import Lens.Micro ((.~)) + +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) + -- 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 ) + ] From 758dc868ec1184ee5e687ef9fef610f49d0f278e Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Tue, 12 Nov 2019 23:38:40 -0500 Subject: [PATCH 11/61] implemented Mtlstats.Control.EditGoalie.header --- src/Mtlstats/Control/EditGoalie.hs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index 12f2fa6..e4fcc8c 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -23,6 +23,7 @@ along with this program. If not, see . module Mtlstats.Control.EditGoalie (editGoalieC) where +import Data.Maybe (fromMaybe) import Lens.Micro ((^.)) import UI.NCurses as C @@ -31,6 +32,7 @@ import Mtlstats.Menu.EditGoalie import Mtlstats.Prompt import Mtlstats.Prompt.EditGoalie import Mtlstats.Types +import Mtlstats.Util -- | Controller/dispatcher for editing a 'Goalie' editGoalieC :: EditGoalieState -> Controller @@ -113,4 +115,23 @@ ltTiesC :: Controller ltTiesC = undefined header :: ProgState -> C.Update () -header = undefined +header s = C.drawString $ fromMaybe "" $ do + gid <- s^.progMode.editGoalieStateL.egsSelectedGoalie + g <- nth gid $ s^.database.dbGoalies + Just $ unlines + [ " Goalie number: " ++ show (g^.gNumber) + , " Goalie name: " ++ g^.gName + , " YTD games played: " ++ show (g^.gYtd.gsGames) + , " YTD mins played: " ++ show (g^.gYtd.gsMinsPlayed) + , " YTD goals allowed: " ++ show (g^.gYtd.gsGoalsAllowed) + , " YTD wins: " ++ show (g^.gYtd.gsWins) + , " YTD losses: " ++ show (g^.gYtd.gsLosses) + , " YTD ties: " ++ show (g^.gYtd.gsTies) + , " Lifetime games played: " ++ show (g^.gLifetime.gsGames) + , " Lifetime mins played: " ++ show (g^.gLifetime.gsMinsPlayed) + , "Lifetime goals allowed: " ++ show (g^.gLifetime.gsGoalsAllowed) + , " Lifetime wins: " ++ show (g^.gLifetime.gsWins) + , " Lifetime losses: " ++ show (g^.gLifetime.gsLosses) + , " Lifetime ties: " ++ show (g^.gLifetime.gsTies) + , "" + ] From d1773324d511b5564673d6cf73540b1123f20d27 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Tue, 12 Nov 2019 23:44:39 -0500 Subject: [PATCH 12/61] added "Edit Goalie" to main menu --- src/Mtlstats/Actions.hs | 5 +++++ src/Mtlstats/Menu.hs | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions.hs b/src/Mtlstats/Actions.hs index 2e59846..2b3942d 100644 --- a/src/Mtlstats/Actions.hs +++ b/src/Mtlstats/Actions.hs @@ -30,6 +30,7 @@ module Mtlstats.Actions , createPlayer , createGoalie , editPlayer + , editGoalie , addPlayer , addGoalie , resetCreatePlayerState @@ -93,6 +94,10 @@ createGoalie = let editPlayer :: ProgState -> ProgState editPlayer = progMode .~ EditPlayer newEditPlayerState +-- | Starts the 'Goalie' editing process +editGoalie :: ProgState -> ProgState +editGoalie = undefined + -- | Adds the entered player to the roster addPlayer :: ProgState -> ProgState addPlayer s = fromMaybe s $ do diff --git a/src/Mtlstats/Menu.hs b/src/Mtlstats/Menu.hs index 4967b2a..b2c04e1 100644 --- a/src/Mtlstats/Menu.hs +++ b/src/Mtlstats/Menu.hs @@ -104,7 +104,9 @@ mainMenu = Menu "*** MAIN MENU ***" True modify createGoalie >> return True , MenuItem '5' "Edit Player" $ modify editPlayer >> return True - , MenuItem '6' "Exit" $ do + , MenuItem '6' "Edit Goalie" $ + modify editGoalie >> return True + , MenuItem 'X' "Exit" $ do db <- gets $ view database liftIO $ do dir <- getAppUserDataDirectory appName From c24016210cde12156b1f9bbd8b9607c454c6a7c9 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Tue, 12 Nov 2019 23:48:31 -0500 Subject: [PATCH 13/61] implemented editGoalie --- src/Mtlstats/Actions.hs | 2 +- test/ActionsSpec.hs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions.hs b/src/Mtlstats/Actions.hs index 2b3942d..698ac0b 100644 --- a/src/Mtlstats/Actions.hs +++ b/src/Mtlstats/Actions.hs @@ -96,7 +96,7 @@ editPlayer = progMode .~ EditPlayer newEditPlayerState -- | Starts the 'Goalie' editing process editGoalie :: ProgState -> ProgState -editGoalie = undefined +editGoalie = progMode .~ EditGoalie newEditGoalieState -- | Adds the entered player to the roster addPlayer :: ProgState -> ProgState diff --git a/test/ActionsSpec.hs b/test/ActionsSpec.hs index 19c4114..b6883c9 100644 --- a/test/ActionsSpec.hs +++ b/test/ActionsSpec.hs @@ -51,6 +51,7 @@ spec = describe "Mtlstats.Actions" $ do createPlayerSpec createGoalieSpec editPlayerSpec + editGoalieSpec addPlayerSpec addGoalieSpec resetCreatePlayerStateSpec @@ -165,6 +166,12 @@ editPlayerSpec = describe "editPlayer" $ s = editPlayer newProgState in show (s^.progMode) `shouldBe` "EditPlayer" +editGoalieSpec :: Spec +editGoalieSpec = describe "editGoalie" $ + it "should change the mode appropriately" $ let + s = editGoalie newProgState + in show (s^.progMode) `shouldBe` "EditGoalie" + addPlayerSpec :: Spec addPlayerSpec = describe "addPlayer" $ do let From 75abf0ade80d3c7c222764c82acd4ed464a6b70f Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Tue, 12 Nov 2019 23:51:49 -0500 Subject: [PATCH 14/61] implemented Mtlstats.Control.EditGoalie.numberC --- src/Mtlstats/Control/EditGoalie.hs | 2 +- src/Mtlstats/Prompt/EditGoalie.hs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index e4fcc8c..52653c2 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -67,7 +67,7 @@ menuC :: Controller menuC = menuControllerWith header editGoalieMenu numberC :: Controller -numberC = undefined +numberC = promptController editGoalieNumberPrompt nameC :: Controller nameC = undefined diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index 99f9c26..b70e4b6 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -19,7 +19,10 @@ along with this program. If not, see . -} -module Mtlstats.Prompt.EditGoalie (goalieToEditPrompt) where +module Mtlstats.Prompt.EditGoalie + ( goalieToEditPrompt + , editGoalieNumberPrompt + ) where import Control.Monad.Trans.State (modify) import Lens.Micro ((.~)) @@ -31,3 +34,7 @@ import Mtlstats.Types goalieToEditPrompt :: Prompt goalieToEditPrompt = selectGoaliePrompt "Goalie to edit: " $ modify . (progMode.editGoalieStateL.egsSelectedGoalie .~) + +-- | Prompt to edit a goalie's number +editGoalieNumberPrompt :: Prompt +editGoalieNumberPrompt = undefined From 0202ddadabc742e06e8d9e8741b4a2261d77c7c3 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Tue, 12 Nov 2019 23:58:17 -0500 Subject: [PATCH 15/61] implemented editGoalieNumberPrompt --- src/Mtlstats/Actions/EditGoalie.hs | 34 ++++++++++++++++++++++++++++++ src/Mtlstats/Prompt/EditGoalie.hs | 4 +++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/Mtlstats/Actions/EditGoalie.hs diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs new file mode 100644 index 0000000..ebc46a1 --- /dev/null +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -0,0 +1,34 @@ +{- | + +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.Actions.EditGoalie + ( setGoalieNumber + ) where + +import Mtlstats.Types + +-- | Sets a goalie's number +setGoalieNumber + :: Int + -- ^ New goalie number + -> ProgState + -> ProgState +setGoalieNumber = undefined diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index b70e4b6..4ac60f1 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -27,6 +27,7 @@ module Mtlstats.Prompt.EditGoalie import Control.Monad.Trans.State (modify) import Lens.Micro ((.~)) +import Mtlstats.Actions.EditGoalie import Mtlstats.Prompt import Mtlstats.Types @@ -37,4 +38,5 @@ goalieToEditPrompt = selectGoaliePrompt "Goalie to edit: " $ -- | Prompt to edit a goalie's number editGoalieNumberPrompt :: Prompt -editGoalieNumberPrompt = undefined +editGoalieNumberPrompt = numPrompt "Goalie number: " $ + modify . setGoalieNumber From 0b3d70e7c39bd6678aa2737aad377d34e8d78753 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Wed, 13 Nov 2019 01:07:23 -0500 Subject: [PATCH 16/61] implemented setGoalieNumber --- src/Mtlstats/Actions/EditGoalie.hs | 13 +++- test/Actions/EditGoalieSpec.hs | 109 +++++++++++++++++++++++++++++ test/ActionsSpec.hs | 2 + 3 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 test/Actions/EditGoalieSpec.hs diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index ebc46a1..fdc599e 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -23,7 +23,12 @@ module Mtlstats.Actions.EditGoalie ( setGoalieNumber ) where +import Control.Monad (void) +import Data.Maybe (fromMaybe) +import Lens.Micro ((^.), (&), (.~), (%~)) + import Mtlstats.Types +import Mtlstats.Util -- | Sets a goalie's number setGoalieNumber @@ -31,4 +36,10 @@ setGoalieNumber -- ^ New goalie number -> ProgState -> ProgState -setGoalieNumber = undefined +setGoalieNumber n s = fromMaybe s $ do + gid <- s^.progMode.editGoalieStateL.egsSelectedGoalie + void $ nth gid $ s^.database.dbGoalies + let updateGoalie = gNumber .~ n + Just $ s + & database.dbGoalies %~ modifyNth gid updateGoalie + & progMode.editGoalieStateL.egsMode .~ EGMenu diff --git a/test/Actions/EditGoalieSpec.hs b/test/Actions/EditGoalieSpec.hs new file mode 100644 index 0000000..5dcb9ac --- /dev/null +++ b/test/Actions/EditGoalieSpec.hs @@ -0,0 +1,109 @@ +{- + +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 Actions.EditGoalieSpec (spec) where + +import Data.Maybe (fromJust) +import Lens.Micro ((^.), (&), (.~)) +import Test.Hspec (Spec, context, describe, it, shouldBe) + +import Mtlstats.Actions.EditGoalie +import Mtlstats.Types +import Mtlstats.Util + +spec :: Spec +spec = describe "EditGoalie" + setGoalieNumberSpec + +setGoalieNumberSpec :: Spec +setGoalieNumberSpec = describe "setGoalieNumber" $ do + let + joe = newGoalie 2 "Joe" + bob = newGoalie 3 "Bob" + db = newDatabase & dbGoalies .~ [joe, bob] + + progState m = newProgState + & progMode .~ m + & database .~ db + & setGoalieNumber 5 + + mapM_ + (\(setLabel, setGid, mode, joeData, bobData) -> context setLabel $ do + let + egs = newEditGoalieState + & egsSelectedGoalie .~ setGid + & egsMode .~ EGNumber + + pm = EditGoalie egs + ps = progState pm + + mapM_ + (\(chkLabel, chkGid, (number, name)) -> context chkLabel $ let + g = fromJust $ nth chkGid $ ps^.database.dbGoalies + + in context "check goalie" $ let + expected = newGoalie number name + in it ("should be " ++ show expected) $ + g `shouldBe` expected) + + -- label, goalie ID, data + [ ( "check Joe", 0, joeData ) + , ( "check Bob", 1, bobData ) + ] + + context "check mode" $ + it ("should be " ++ show mode) $ + ps^.progMode.editGoalieStateL.egsMode `shouldBe` mode) + + [ ( "set Joe" + , Just 0 + , EGMenu + , (5, "Joe") + , (3, "Bob") + ) + , ( "set Bob" + , Just 1 + , EGMenu + , (2, "Joe") + , (5, "Bob") + ) + , ( "out of bounds" + , Just 2 + , EGNumber + , (2, "Joe") + , (3, "Bob") + ) + , ( "no goalie selected" + , Nothing + , EGNumber + , (2, "Joe") + , (3, "Bob") + ) + ] + + context "wrong progMode" $ do + let ps = progState MainMenu + + it "should not change the database" $ + ps^.database `shouldBe` db + + it "should not change the progMode" $ + show (ps^.progMode) `shouldBe` "MainMenu" diff --git a/test/ActionsSpec.hs b/test/ActionsSpec.hs index b6883c9..19a16f3 100644 --- a/test/ActionsSpec.hs +++ b/test/ActionsSpec.hs @@ -38,6 +38,7 @@ import Test.Hspec import Mtlstats.Actions import Mtlstats.Types +import qualified Actions.EditGoalieSpec as EditGoalie import qualified Actions.NewGameSpec as NewGame import qualified TypesSpec as TS @@ -60,6 +61,7 @@ spec = describe "Mtlstats.Actions" $ do scrollUpSpec scrollDownSpec NewGame.spec + EditGoalie.spec startNewSeasonSpec :: Spec startNewSeasonSpec = describe "startNewSeason" $ do From 6c4b08bfcdb651c08f0e517ad5d005298b5f4bb9 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Wed, 13 Nov 2019 11:06:12 -0500 Subject: [PATCH 17/61] renaned setGoalieNumber to editGoalieNumber --- src/Mtlstats/Actions/EditGoalie.hs | 8 ++++---- src/Mtlstats/Prompt/EditGoalie.hs | 2 +- test/Actions/EditGoalieSpec.hs | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index fdc599e..e896ded 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -20,7 +20,7 @@ along with this program. If not, see . -} module Mtlstats.Actions.EditGoalie - ( setGoalieNumber + ( editGoalieNumber ) where import Control.Monad (void) @@ -30,13 +30,13 @@ import Lens.Micro ((^.), (&), (.~), (%~)) import Mtlstats.Types import Mtlstats.Util --- | Sets a goalie's number -setGoalieNumber +-- | Edits a goalie's number +editGoalieNumber :: Int -- ^ New goalie number -> ProgState -> ProgState -setGoalieNumber n s = fromMaybe s $ do +editGoalieNumber n s = fromMaybe s $ do gid <- s^.progMode.editGoalieStateL.egsSelectedGoalie void $ nth gid $ s^.database.dbGoalies let updateGoalie = gNumber .~ n diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index 4ac60f1..e662ce4 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -39,4 +39,4 @@ goalieToEditPrompt = selectGoaliePrompt "Goalie to edit: " $ -- | Prompt to edit a goalie's number editGoalieNumberPrompt :: Prompt editGoalieNumberPrompt = numPrompt "Goalie number: " $ - modify . setGoalieNumber + modify . editGoalieNumber diff --git a/test/Actions/EditGoalieSpec.hs b/test/Actions/EditGoalieSpec.hs index 5dcb9ac..8c25851 100644 --- a/test/Actions/EditGoalieSpec.hs +++ b/test/Actions/EditGoalieSpec.hs @@ -31,10 +31,10 @@ import Mtlstats.Util spec :: Spec spec = describe "EditGoalie" - setGoalieNumberSpec + editGoalieNumberSpec -setGoalieNumberSpec :: Spec -setGoalieNumberSpec = describe "setGoalieNumber" $ do +editGoalieNumberSpec :: Spec +editGoalieNumberSpec = describe "editGoalieNumber" $ do let joe = newGoalie 2 "Joe" bob = newGoalie 3 "Bob" @@ -43,7 +43,7 @@ setGoalieNumberSpec = describe "setGoalieNumber" $ do progState m = newProgState & progMode .~ m & database .~ db - & setGoalieNumber 5 + & editGoalieNumber 5 mapM_ (\(setLabel, setGid, mode, joeData, bobData) -> context setLabel $ do From 895f090f1789fbc2e5ff2bd926d4a7f964b5a884 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Wed, 13 Nov 2019 11:34:25 -0500 Subject: [PATCH 18/61] implenented Mtlstats.Control.EditGoalie.nameC --- src/Mtlstats/Control/EditGoalie.hs | 2 +- src/Mtlstats/Prompt/EditGoalie.hs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index 52653c2..802b3b1 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -70,7 +70,7 @@ numberC :: Controller numberC = promptController editGoalieNumberPrompt nameC :: Controller -nameC = undefined +nameC = promptController editGoalieNamePrompt ytdMenuC :: Controller ytdMenuC = undefined diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index e662ce4..085fb97 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -22,6 +22,7 @@ along with this program. If not, see . module Mtlstats.Prompt.EditGoalie ( goalieToEditPrompt , editGoalieNumberPrompt + , editGoalieNamePrompt ) where import Control.Monad.Trans.State (modify) @@ -40,3 +41,7 @@ goalieToEditPrompt = selectGoaliePrompt "Goalie to edit: " $ editGoalieNumberPrompt :: Prompt editGoalieNumberPrompt = numPrompt "Goalie number: " $ modify . editGoalieNumber + +-- | Prompt to edit a goalie's name +editGoalieNamePrompt :: Prompt +editGoalieNamePrompt = undefined From fceba7eed1c66e064e353ebf0aa16d94f6670055 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Wed, 13 Nov 2019 11:40:02 -0500 Subject: [PATCH 19/61] implemented editGoalieNamePrompt --- src/Mtlstats/Actions/EditGoalie.hs | 9 +++++++++ src/Mtlstats/Prompt/EditGoalie.hs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index e896ded..39b38d4 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -21,6 +21,7 @@ along with this program. If not, see . module Mtlstats.Actions.EditGoalie ( editGoalieNumber + , editGoalieName ) where import Control.Monad (void) @@ -43,3 +44,11 @@ editGoalieNumber n s = fromMaybe s $ do Just $ s & database.dbGoalies %~ modifyNth gid updateGoalie & progMode.editGoalieStateL.egsMode .~ EGMenu + +-- | Edits a goalie's name +editGoalieName + :: String + -- ^ The new name + -> ProgState + -> ProgState +editGoalieName = undefined diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index 085fb97..443e2a3 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -44,4 +44,5 @@ editGoalieNumberPrompt = numPrompt "Goalie number: " $ -- | Prompt to edit a goalie's name editGoalieNamePrompt :: Prompt -editGoalieNamePrompt = undefined +editGoalieNamePrompt = strPrompt "Goalie name: " $ + modify . editGoalieName From 61ba781c5dbc38901517ed9c682c1685637c3edf Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Wed, 13 Nov 2019 23:50:02 -0500 Subject: [PATCH 20/61] implemented editGoalieName --- src/Mtlstats/Actions/EditGoalie.hs | 18 ++-- test/Actions/EditGoalieSpec.hs | 150 +++++++++++++++++++---------- 2 files changed, 107 insertions(+), 61 deletions(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 39b38d4..30e8213 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -37,13 +37,7 @@ editGoalieNumber -- ^ New goalie number -> ProgState -> ProgState -editGoalieNumber n s = fromMaybe s $ do - gid <- s^.progMode.editGoalieStateL.egsSelectedGoalie - void $ nth gid $ s^.database.dbGoalies - let updateGoalie = gNumber .~ n - Just $ s - & database.dbGoalies %~ modifyNth gid updateGoalie - & progMode.editGoalieStateL.egsMode .~ EGMenu +editGoalieNumber num = editGoalie (gNumber .~ num) EGMenu -- | Edits a goalie's name editGoalieName @@ -51,4 +45,12 @@ editGoalieName -- ^ The new name -> ProgState -> ProgState -editGoalieName = undefined +editGoalieName name = editGoalie (gName .~ name) EGMenu + +editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState +editGoalie f mode s = fromMaybe s $ do + gid <- s^.progMode.editGoalieStateL.egsSelectedGoalie + void $ nth gid $ s^.database.dbGoalies + Just $ s + & database.dbGoalies %~ modifyNth gid f + & progMode.editGoalieStateL.egsMode .~ mode diff --git a/test/Actions/EditGoalieSpec.hs b/test/Actions/EditGoalieSpec.hs index 8c25851..8dec3bd 100644 --- a/test/Actions/EditGoalieSpec.hs +++ b/test/Actions/EditGoalieSpec.hs @@ -30,80 +30,124 @@ import Mtlstats.Types import Mtlstats.Util spec :: Spec -spec = describe "EditGoalie" +spec = describe "EditGoalie" $ do editGoalieNumberSpec + editGoalieNameSpec editGoalieNumberSpec :: Spec -editGoalieNumberSpec = describe "editGoalieNumber" $ do - let - joe = newGoalie 2 "Joe" - bob = newGoalie 3 "Bob" - db = newDatabase & dbGoalies .~ [joe, bob] +editGoalieNumberSpec = describe "editGoalieNumber" $ editTest + (editGoalieNumber 5) + EGNumber + (uncurry newGoalie) + [ ( "set Joe" + , Just 0 + , (5, "Joe") + , (3, "Bob") + , EGMenu + ) + , ( "set Bob" + , Just 1 + , (2, "Joe") + , (5, "Bob") + , EGMenu + ) + , ( "out of bounds" + , Just 2 + , (2, "Joe") + , (3, "Bob") + , EGNumber + ) + , ( "no goalie selected" + , Nothing + , (2, "Joe") + , (3, "Bob") + , EGNumber + ) + ] - progState m = newProgState - & progMode .~ m - & database .~ db - & editGoalieNumber 5 +editGoalieNameSpec :: Spec +editGoalieNameSpec = describe "editGoalieName" $ editTest + (editGoalieName "foo") + EGName + (uncurry newGoalie) + [ ( "set Joe" + , Just 0 + , ( 2, "foo" ) + , ( 3, "Bob" ) + , EGMenu + ) + , ( "set Bob" + , Just 1 + , ( 2, "Joe" ) + , ( 3, "foo" ) + , EGMenu + ) + , ( "out of bounds" + , Just 2 + , ( 2, "Joe" ) + , ( 3, "Bob" ) + , EGName + ) + , ( "no goalie selected" + , Nothing + , ( 2, "Joe" ) + , ( 3, "Bob" ) + , EGName + ) + ] +editTest + :: (ProgState -> ProgState) + -> EditGoalieMode + -> (a -> Goalie) + -> [(String, Maybe Int, a, a, EditGoalieMode)] + -> Spec +editTest func setMode mkGoalie params = do mapM_ - (\(setLabel, setGid, mode, joeData, bobData) -> context setLabel $ do + (\(setLabel, setGid, joeData, bobData, expectMode) -> context setLabel $ do let egs = newEditGoalieState & egsSelectedGoalie .~ setGid - & egsMode .~ EGNumber + & egsMode .~ setMode - pm = EditGoalie egs - ps = progState pm + ps = func $ progState $ EditGoalie egs mapM_ - (\(chkLabel, chkGid, (number, name)) -> context chkLabel $ let - g = fromJust $ nth chkGid $ ps^.database.dbGoalies - - in context "check goalie" $ let - expected = newGoalie number name - in it ("should be " ++ show expected) $ - g `shouldBe` expected) - - -- label, goalie ID, data - [ ( "check Joe", 0, joeData ) - , ( "check Bob", 1, bobData ) + (\(chkLabel, chkGid, goalieData) -> context chkLabel $ let + actual = fromJust $ nth chkGid $ ps^.database.dbGoalies + expected = mkGoalie goalieData + in it ("should be " ++ show expected) $ + actual `shouldBe` expected) + -- label, goalie ID, goalie data + [ ( "check Joe", 0, joeData ) + , ( "check Bob", 1, bobData ) ] context "check mode" $ - it ("should be " ++ show mode) $ - ps^.progMode.editGoalieStateL.egsMode `shouldBe` mode) + it ("should be " ++ show expectMode) $ + ps^.progMode.editGoalieStateL.egsMode `shouldBe` expectMode) - [ ( "set Joe" - , Just 0 - , EGMenu - , (5, "Joe") - , (3, "Bob") - ) - , ( "set Bob" - , Just 1 - , EGMenu - , (2, "Joe") - , (5, "Bob") - ) - , ( "out of bounds" - , Just 2 - , EGNumber - , (2, "Joe") - , (3, "Bob") - ) - , ( "no goalie selected" - , Nothing - , EGNumber - , (2, "Joe") - , (3, "Bob") - ) - ] + params context "wrong progMode" $ do - let ps = progState MainMenu + let ps = func $ progState MainMenu it "should not change the database" $ ps^.database `shouldBe` db it "should not change the progMode" $ show (ps^.progMode) `shouldBe` "MainMenu" + +joe :: Goalie +joe = newGoalie 2 "Joe" + +bob :: Goalie +bob = newGoalie 3 "Bob" + +db :: Database +db = newDatabase & dbGoalies .~ [joe, bob] + +progState :: ProgMode -> ProgState +progState mode = newProgState + & progMode .~ mode + & database .~ db From 35eda4a309ce3040f838ffe7e14507828633eefa Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Wed, 13 Nov 2019 23:54:09 -0500 Subject: [PATCH 21/61] implemented Mtlstats.Control.EditGoalie.ytdMenuC --- src/Mtlstats/Control/EditGoalie.hs | 2 +- src/Mtlstats/Menu/EditGoalie.hs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index 802b3b1..f9d6f8f 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -73,7 +73,7 @@ nameC :: Controller nameC = promptController editGoalieNamePrompt ytdMenuC :: Controller -ytdMenuC = undefined +ytdMenuC = menuControllerWith header editGoalieYtdMenu lifetimeMenuC :: Controller lifetimeMenuC = undefined diff --git a/src/Mtlstats/Menu/EditGoalie.hs b/src/Mtlstats/Menu/EditGoalie.hs index d685255..3023747 100644 --- a/src/Mtlstats/Menu/EditGoalie.hs +++ b/src/Mtlstats/Menu/EditGoalie.hs @@ -19,7 +19,10 @@ along with this program. If not, see . -} -module Mtlstats.Menu.EditGoalie (editGoalieMenu) where +module Mtlstats.Menu.EditGoalie + ( editGoalieMenu + , editGoalieYtdMenu + ) where import Control.Monad.Trans.State (modify) import Data.Maybe (maybe) @@ -42,3 +45,7 @@ editGoalieMenu = Menu "*** EDIT GOALTENDER ***" () $ map , ( '4', "Edit Lifetime stats", Just EGLifetime ) , ( 'R', "Return to Main Menu", Nothing ) ] + +-- | The 'Goalie' YTD edit menu +editGoalieYtdMenu :: Menu () +editGoalieYtdMenu = undefined From 9682aa0af325e3140a9af88b196a2ad2cb8beac9 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 00:26:17 -0500 Subject: [PATCH 22/61] implemented editGoalieYtdMenu --- src/Mtlstats/Menu/EditGoalie.hs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Menu/EditGoalie.hs b/src/Mtlstats/Menu/EditGoalie.hs index 3023747..c1857aa 100644 --- a/src/Mtlstats/Menu/EditGoalie.hs +++ b/src/Mtlstats/Menu/EditGoalie.hs @@ -48,4 +48,15 @@ editGoalieMenu = Menu "*** EDIT GOALTENDER ***" () $ map -- | The 'Goalie' YTD edit menu editGoalieYtdMenu :: Menu () -editGoalieYtdMenu = undefined +editGoalieYtdMenu = Menu "*** EDIT GOALTENDER YEAR-TO-DATE ***" () $ map + (\(key, label, val) -> MenuItem key label $ + modify $ progMode.editGoalieStateL.egsMode .~ val) + -- key, label, value + [ ( '1', "Edit YTD games", EGYtdGames ) + , ( '2', "Edit YTD minutes", EGYtdMins ) + , ( '3', "Edit YTD goals", EGYtdGoals ) + , ( '4', "Edit YTD wins", EGYtdWins ) + , ( '5', "Edit YTD losses", EGYtdLosses ) + , ( '6', "Edit YTD ties", EGYtdTies ) + , ( 'R', "Return to edit menu", EGMenu ) + ] From 0234abec4c8b8d2c77b7157c4f57c5b33658f6c9 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 00:28:48 -0500 Subject: [PATCH 23/61] implemented Mtlstats.Control.EditGoalie.lifetimeMenuC --- src/Mtlstats/Control/EditGoalie.hs | 2 +- src/Mtlstats/Menu/EditGoalie.hs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index f9d6f8f..8d7eefa 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -76,7 +76,7 @@ ytdMenuC :: Controller ytdMenuC = menuControllerWith header editGoalieYtdMenu lifetimeMenuC :: Controller -lifetimeMenuC = undefined +lifetimeMenuC = menuControllerWith header editGoalieLtMenu ytdGamesC :: Controller ytdGamesC = undefined diff --git a/src/Mtlstats/Menu/EditGoalie.hs b/src/Mtlstats/Menu/EditGoalie.hs index c1857aa..951184b 100644 --- a/src/Mtlstats/Menu/EditGoalie.hs +++ b/src/Mtlstats/Menu/EditGoalie.hs @@ -22,6 +22,7 @@ along with this program. If not, see . module Mtlstats.Menu.EditGoalie ( editGoalieMenu , editGoalieYtdMenu + , editGoalieLtMenu ) where import Control.Monad.Trans.State (modify) @@ -60,3 +61,7 @@ editGoalieYtdMenu = Menu "*** EDIT GOALTENDER YEAR-TO-DATE ***" () $ map , ( '6', "Edit YTD ties", EGYtdTies ) , ( 'R', "Return to edit menu", EGMenu ) ] + +-- | The 'Goalie' lifetime edit menu +editGoalieLtMenu :: Menu () +editGoalieLtMenu = undefined From 3839d6dd32d8705b4bb71a82c0eb89cf3b73907d Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 00:40:09 -0500 Subject: [PATCH 24/61] implemented editGoalieLtMenu --- src/Mtlstats/Menu/EditGoalie.hs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Mtlstats/Menu/EditGoalie.hs b/src/Mtlstats/Menu/EditGoalie.hs index 951184b..ce5b531 100644 --- a/src/Mtlstats/Menu/EditGoalie.hs +++ b/src/Mtlstats/Menu/EditGoalie.hs @@ -49,9 +49,7 @@ editGoalieMenu = Menu "*** EDIT GOALTENDER ***" () $ map -- | The 'Goalie' YTD edit menu editGoalieYtdMenu :: Menu () -editGoalieYtdMenu = Menu "*** EDIT GOALTENDER YEAR-TO-DATE ***" () $ map - (\(key, label, val) -> MenuItem key label $ - modify $ progMode.editGoalieStateL.egsMode .~ val) +editGoalieYtdMenu = editMenu "*** EDIT GOALTENDER YEAR-TO-DATE ***" -- key, label, value [ ( '1', "Edit YTD games", EGYtdGames ) , ( '2', "Edit YTD minutes", EGYtdMins ) @@ -64,4 +62,19 @@ editGoalieYtdMenu = Menu "*** EDIT GOALTENDER YEAR-TO-DATE ***" () $ map -- | The 'Goalie' lifetime edit menu editGoalieLtMenu :: Menu () -editGoalieLtMenu = undefined +editGoalieLtMenu = editMenu + "*** EDIT GOALTENDER LIFETIME ***" + -- key, label, value + [ ( '1', "Edit lifetime games", EGLtGames ) + , ( '2', "Edit lifetime minutes", EGLtMins ) + , ( '3', "Edit lifetime goals", EGLtGoals ) + , ( '4', "Edit lifetime wins", EGLtWins ) + , ( '5', "Edit lifetime losses", EGLtLosses ) + , ( '6', "Edit lifetime ties", EGLtTies ) + , ( 'R', "Return to edit menu", EGMenu ) + ] + +editMenu :: String -> [(Char, String, EditGoalieMode)] -> Menu () +editMenu title = Menu title () . map + (\(key, label, val) -> MenuItem key label $ + modify $ progMode.editGoalieStateL.egsMode .~ val) From 06348fe9289a4b64e0567e4c2a9d0b9073c0bdc5 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 00:44:38 -0500 Subject: [PATCH 25/61] implemented Mtlstats.Control.EditGoalie.ytdGamesC --- src/Mtlstats/Control/EditGoalie.hs | 2 +- src/Mtlstats/Prompt/EditGoalie.hs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index 8d7eefa..7f21af6 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -79,7 +79,7 @@ lifetimeMenuC :: Controller lifetimeMenuC = menuControllerWith header editGoalieLtMenu ytdGamesC :: Controller -ytdGamesC = undefined +ytdGamesC = promptController editGoalieYtdGamesPrompt ytdMinsC :: Controller ytdMinsC = undefined diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index 443e2a3..2f9224d 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -23,6 +23,7 @@ module Mtlstats.Prompt.EditGoalie ( goalieToEditPrompt , editGoalieNumberPrompt , editGoalieNamePrompt + , editGoalieYtdGamesPrompt ) where import Control.Monad.Trans.State (modify) @@ -46,3 +47,7 @@ editGoalieNumberPrompt = numPrompt "Goalie number: " $ editGoalieNamePrompt :: Prompt editGoalieNamePrompt = strPrompt "Goalie name: " $ modify . editGoalieName + +-- | Prompt to edit a goalie's YTD games played +editGoalieYtdGamesPrompt :: Prompt +editGoalieYtdGamesPrompt = undefined From f739db4203f1cfd5f98c62fa8c7b4f2e6279e32b Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 00:48:41 -0500 Subject: [PATCH 26/61] implemented editGoalieYtdGamesPrompt --- src/Mtlstats/Actions/EditGoalie.hs | 9 +++++++++ src/Mtlstats/Prompt/EditGoalie.hs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 30e8213..8e5e9bb 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -22,6 +22,7 @@ along with this program. If not, see . module Mtlstats.Actions.EditGoalie ( editGoalieNumber , editGoalieName + , editGoalieYtdGames ) where import Control.Monad (void) @@ -47,6 +48,14 @@ editGoalieName -> ProgState editGoalieName name = editGoalie (gName .~ name) EGMenu +-- | Edits a goalie's YTD games +editGoalieYtdGames + :: Int + -- ^ The number of games played + -> ProgState + -> ProgState +editGoalieYtdGames = undefined + editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do gid <- s^.progMode.editGoalieStateL.egsSelectedGoalie diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index 2f9224d..aac4311 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -50,4 +50,5 @@ editGoalieNamePrompt = strPrompt "Goalie name: " $ -- | Prompt to edit a goalie's YTD games played editGoalieYtdGamesPrompt :: Prompt -editGoalieYtdGamesPrompt = undefined +editGoalieYtdGamesPrompt = numPrompt "Year-to-date games played: " $ + modify . editGoalieYtdGames From 203650397ee186110024149f438199e2ce9c9b05 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 00:59:00 -0500 Subject: [PATCH 27/61] implemented editGoalieYtdGames --- src/Mtlstats/Actions/EditGoalie.hs | 2 +- test/Actions/EditGoalieSpec.hs | 32 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 8e5e9bb..ebc5ba2 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -54,7 +54,7 @@ editGoalieYtdGames -- ^ The number of games played -> ProgState -> ProgState -editGoalieYtdGames = undefined +editGoalieYtdGames games = editGoalie (gYtd.gsGames .~ games) EGYtd editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do diff --git a/test/Actions/EditGoalieSpec.hs b/test/Actions/EditGoalieSpec.hs index 8dec3bd..f826e47 100644 --- a/test/Actions/EditGoalieSpec.hs +++ b/test/Actions/EditGoalieSpec.hs @@ -33,6 +33,7 @@ spec :: Spec spec = describe "EditGoalie" $ do editGoalieNumberSpec editGoalieNameSpec + editGoalieYtdGamesSpec editGoalieNumberSpec :: Spec editGoalieNumberSpec = describe "editGoalieNumber" $ editTest @@ -96,6 +97,37 @@ editGoalieNameSpec = describe "editGoalieName" $ editTest ) ] +editGoalieYtdGamesSpec :: Spec +editGoalieYtdGamesSpec = describe "editGoalieYtdGames" $ editTest + (editGoalieYtdGames 1) + EGYtdGames + (\(num, name, games) -> newGoalie num name & gYtd.gsGames .~ games) + [ ( "set Joe" + , Just 0 + , ( 2, "Joe", 1 ) + , ( 3, "Bob", 0 ) + , EGYtd + ) + , ( "set Bob" + , Just 1 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 1 ) + , EGYtd + ) + , ( "out of bounds" + , Just 2 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGYtdGames + ) + , ( "no goalie selected" + , Nothing + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGYtdGames + ) + ] + editTest :: (ProgState -> ProgState) -> EditGoalieMode From 1b9c072a765c18abad7b99de90a0e41d1938aaf2 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 01:01:30 -0500 Subject: [PATCH 28/61] implemented Mtlstats.Control.EditGoalie.ytdMinsC --- src/Mtlstats/Control/EditGoalie.hs | 2 +- src/Mtlstats/Prompt/EditGoalie.hs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index 7f21af6..e5bec42 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -82,7 +82,7 @@ ytdGamesC :: Controller ytdGamesC = promptController editGoalieYtdGamesPrompt ytdMinsC :: Controller -ytdMinsC = undefined +ytdMinsC = promptController editGoalieYtdMinsPrompt ytdGoalsC :: Controller ytdGoalsC = undefined diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index aac4311..e36dc99 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -24,6 +24,7 @@ module Mtlstats.Prompt.EditGoalie , editGoalieNumberPrompt , editGoalieNamePrompt , editGoalieYtdGamesPrompt + , editGoalieYtdMinsPrompt ) where import Control.Monad.Trans.State (modify) @@ -52,3 +53,7 @@ editGoalieNamePrompt = strPrompt "Goalie name: " $ editGoalieYtdGamesPrompt :: Prompt editGoalieYtdGamesPrompt = numPrompt "Year-to-date games played: " $ modify . editGoalieYtdGames + +-- | Prompt to edit a goalie's YTD minutes played +editGoalieYtdMinsPrompt :: Prompt +editGoalieYtdMinsPrompt = undefined From 0961f14c5fbecff9b67decafb5b29d68b97dd963 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 01:03:47 -0500 Subject: [PATCH 29/61] implemented editGoalieYtdMinsPrompt --- src/Mtlstats/Actions/EditGoalie.hs | 9 +++++++++ src/Mtlstats/Prompt/EditGoalie.hs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index ebc5ba2..6b8d6b8 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -23,6 +23,7 @@ module Mtlstats.Actions.EditGoalie ( editGoalieNumber , editGoalieName , editGoalieYtdGames + , editGoalieYtdMins ) where import Control.Monad (void) @@ -56,6 +57,14 @@ editGoalieYtdGames -> ProgState editGoalieYtdGames games = editGoalie (gYtd.gsGames .~ games) EGYtd +-- | Edits a goalie's YTD minutes +editGoalieYtdMins + :: Int + -- ^ The number of minutes played + -> ProgState + -> ProgState +editGoalieYtdMins = undefined + editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do gid <- s^.progMode.editGoalieStateL.egsSelectedGoalie diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index e36dc99..8a00818 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -56,4 +56,5 @@ editGoalieYtdGamesPrompt = numPrompt "Year-to-date games played: " $ -- | Prompt to edit a goalie's YTD minutes played editGoalieYtdMinsPrompt :: Prompt -editGoalieYtdMinsPrompt = undefined +editGoalieYtdMinsPrompt = numPrompt "Year-to-date minutes played: " $ + modify . editGoalieYtdMins From 023430d73758d8dbe01c3310f7e5dfb42ad366c7 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 01:11:50 -0500 Subject: [PATCH 30/61] implemented editGoalieYtdMins --- src/Mtlstats/Actions/EditGoalie.hs | 2 +- test/Actions/EditGoalieSpec.hs | 32 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 6b8d6b8..c229283 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -63,7 +63,7 @@ editGoalieYtdMins -- ^ The number of minutes played -> ProgState -> ProgState -editGoalieYtdMins = undefined +editGoalieYtdMins mins = editGoalie (gYtd.gsMinsPlayed .~ mins) EGYtd editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do diff --git a/test/Actions/EditGoalieSpec.hs b/test/Actions/EditGoalieSpec.hs index f826e47..2543395 100644 --- a/test/Actions/EditGoalieSpec.hs +++ b/test/Actions/EditGoalieSpec.hs @@ -34,6 +34,7 @@ spec = describe "EditGoalie" $ do editGoalieNumberSpec editGoalieNameSpec editGoalieYtdGamesSpec + editGoalieYtdMinsSpec editGoalieNumberSpec :: Spec editGoalieNumberSpec = describe "editGoalieNumber" $ editTest @@ -128,6 +129,37 @@ editGoalieYtdGamesSpec = describe "editGoalieYtdGames" $ editTest ) ] +editGoalieYtdMinsSpec :: Spec +editGoalieYtdMinsSpec = describe "editGoalieYtdMins" $ editTest + (editGoalieYtdMins 1) + EGYtdMins + (\(num, name, mins) -> newGoalie num name & gYtd.gsMinsPlayed .~ mins) + [ ( "set Joe" + , Just 0 + , ( 2, "Joe", 1 ) + , ( 3, "Bob", 0 ) + , EGYtd + ) + , ( "set Bob" + , Just 1 + , (2, "Joe", 0 ) + , (3, "Bob", 1 ) + , EGYtd + ) + , ( "out of bounds" + , Just 2 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGYtdMins + ) + , ( "no goalie selected" + , Nothing + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGYtdMins + ) + ] + editTest :: (ProgState -> ProgState) -> EditGoalieMode From 5dcd14028063dac1cbb1358bf7e75a486178df93 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 01:17:19 -0500 Subject: [PATCH 31/61] implemented Mtlstats.Control.EditGoalie.ytdGoalsC --- src/Mtlstats/Control/EditGoalie.hs | 2 +- src/Mtlstats/Prompt/EditGoalie.hs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index e5bec42..686ad47 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -85,7 +85,7 @@ ytdMinsC :: Controller ytdMinsC = promptController editGoalieYtdMinsPrompt ytdGoalsC :: Controller -ytdGoalsC = undefined +ytdGoalsC = promptController editGoalieYtdGoalsPrompt ytdWinsC :: Controller ytdWinsC = undefined diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index 8a00818..eb783e3 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -25,6 +25,7 @@ module Mtlstats.Prompt.EditGoalie , editGoalieNamePrompt , editGoalieYtdGamesPrompt , editGoalieYtdMinsPrompt + , editGoalieYtdGoalsPrompt ) where import Control.Monad.Trans.State (modify) @@ -58,3 +59,7 @@ editGoalieYtdGamesPrompt = numPrompt "Year-to-date games played: " $ editGoalieYtdMinsPrompt :: Prompt editGoalieYtdMinsPrompt = numPrompt "Year-to-date minutes played: " $ modify . editGoalieYtdMins + +-- | Prompt to edit a goalie's YTD goales allowed +editGoalieYtdGoalsPrompt :: Prompt +editGoalieYtdGoalsPrompt = undefined From 817c3c3fed4c914a2f0f79e6af6f863c9a0cd48b Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 01:21:46 -0500 Subject: [PATCH 32/61] implemented editGoalieYtdGoalsPrompt --- src/Mtlstats/Actions/EditGoalie.hs | 9 +++++++++ src/Mtlstats/Prompt/EditGoalie.hs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index c229283..0a7e101 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -24,6 +24,7 @@ module Mtlstats.Actions.EditGoalie , editGoalieName , editGoalieYtdGames , editGoalieYtdMins + , editGoalieYtdGoals ) where import Control.Monad (void) @@ -65,6 +66,14 @@ editGoalieYtdMins -> ProgState editGoalieYtdMins mins = editGoalie (gYtd.gsMinsPlayed .~ mins) EGYtd +-- | Edits a goalie's YTD goals allowed +editGoalieYtdGoals + :: Int + -- ^ The number of goals + -> ProgState + -> ProgState +editGoalieYtdGoals = undefined + editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do gid <- s^.progMode.editGoalieStateL.egsSelectedGoalie diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index eb783e3..c31b0cd 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -62,4 +62,5 @@ editGoalieYtdMinsPrompt = numPrompt "Year-to-date minutes played: " $ -- | Prompt to edit a goalie's YTD goales allowed editGoalieYtdGoalsPrompt :: Prompt -editGoalieYtdGoalsPrompt = undefined +editGoalieYtdGoalsPrompt = numPrompt "Year-to-date goals allowed: " $ + modify . editGoalieYtdGoals From cb5aa63469821a5bfcfbf918a0e3bc1d72abc81f Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 01:32:20 -0500 Subject: [PATCH 33/61] implemented editGoalieYtdGoals --- src/Mtlstats/Actions/EditGoalie.hs | 2 +- test/Actions/EditGoalieSpec.hs | 32 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 0a7e101..ec4a1de 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -72,7 +72,7 @@ editGoalieYtdGoals -- ^ The number of goals -> ProgState -> ProgState -editGoalieYtdGoals = undefined +editGoalieYtdGoals goals = editGoalie (gYtd.gsGoalsAllowed .~ goals) EGYtd editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do diff --git a/test/Actions/EditGoalieSpec.hs b/test/Actions/EditGoalieSpec.hs index 2543395..d407466 100644 --- a/test/Actions/EditGoalieSpec.hs +++ b/test/Actions/EditGoalieSpec.hs @@ -35,6 +35,7 @@ spec = describe "EditGoalie" $ do editGoalieNameSpec editGoalieYtdGamesSpec editGoalieYtdMinsSpec + editGoalieYtdGoalsSpec editGoalieNumberSpec :: Spec editGoalieNumberSpec = describe "editGoalieNumber" $ editTest @@ -160,6 +161,37 @@ editGoalieYtdMinsSpec = describe "editGoalieYtdMins" $ editTest ) ] +editGoalieYtdGoalsSpec :: Spec +editGoalieYtdGoalsSpec = describe "editGoalieYtdGoals" $ editTest + (editGoalieYtdGoals 1) + EGYtdGoals + (\(num, name, goals) -> newGoalie num name & gYtd.gsGoalsAllowed .~ goals) + [ ( "set Joe" + , Just 0 + , ( 2, "Joe", 1 ) + , ( 3, "Bob", 0 ) + , EGYtd + ) + , ( "set Bob" + , Just 1 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 1 ) + , EGYtd + ) + , ( "out of bounds" + , Just 2 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGYtdGoals + ) + , ( "no goalie selected" + , Nothing + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGYtdGoals + ) + ] + editTest :: (ProgState -> ProgState) -> EditGoalieMode From 4f5b4ff5f9e009021e3a55f786692efe616da31d Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 01:37:58 -0500 Subject: [PATCH 34/61] implemented Mtlstats.Control.EditGoalie.ytdWinsC --- src/Mtlstats/Control/EditGoalie.hs | 2 +- src/Mtlstats/Prompt/EditGoalie.hs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index 686ad47..1e5f755 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -88,7 +88,7 @@ ytdGoalsC :: Controller ytdGoalsC = promptController editGoalieYtdGoalsPrompt ytdWinsC :: Controller -ytdWinsC = undefined +ytdWinsC = promptController editGoalieYtdWinsPrompt ytdLossesC :: Controller ytdLossesC = undefined diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index c31b0cd..f3b0aee 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -26,6 +26,7 @@ module Mtlstats.Prompt.EditGoalie , editGoalieYtdGamesPrompt , editGoalieYtdMinsPrompt , editGoalieYtdGoalsPrompt + , editGoalieYtdWinsPrompt ) where import Control.Monad.Trans.State (modify) @@ -64,3 +65,7 @@ editGoalieYtdMinsPrompt = numPrompt "Year-to-date minutes played: " $ editGoalieYtdGoalsPrompt :: Prompt editGoalieYtdGoalsPrompt = numPrompt "Year-to-date goals allowed: " $ modify . editGoalieYtdGoals + +-- | Prompt to edit a goalie's YTD wins +editGoalieYtdWinsPrompt :: Prompt +editGoalieYtdWinsPrompt = undefined From a8a5d6a3057cb881fa1549891cc3c69dc4db60ee Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 01:40:42 -0500 Subject: [PATCH 35/61] implemented editGoalieYtdWinsPrompt --- src/Mtlstats/Actions/EditGoalie.hs | 9 +++++++++ src/Mtlstats/Prompt/EditGoalie.hs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index ec4a1de..9d3dae9 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -25,6 +25,7 @@ module Mtlstats.Actions.EditGoalie , editGoalieYtdGames , editGoalieYtdMins , editGoalieYtdGoals + , editGoalieYtdWins ) where import Control.Monad (void) @@ -74,6 +75,14 @@ editGoalieYtdGoals -> ProgState editGoalieYtdGoals goals = editGoalie (gYtd.gsGoalsAllowed .~ goals) EGYtd +-- | Edits a goalie's YTD wins +editGoalieYtdWins + :: Int + -- ^ The number of wins + -> ProgState + -> ProgState +editGoalieYtdWins = undefined + editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do gid <- s^.progMode.editGoalieStateL.egsSelectedGoalie diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index f3b0aee..6a774ba 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -68,4 +68,5 @@ editGoalieYtdGoalsPrompt = numPrompt "Year-to-date goals allowed: " $ -- | Prompt to edit a goalie's YTD wins editGoalieYtdWinsPrompt :: Prompt -editGoalieYtdWinsPrompt = undefined +editGoalieYtdWinsPrompt = numPrompt "Year-to-date wins: " $ + modify . editGoalieYtdWins From 14da1096cd42211eeb136efe8912480264faaeaf Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 01:47:15 -0500 Subject: [PATCH 36/61] implemented editGoalieYtdWins --- src/Mtlstats/Actions/EditGoalie.hs | 2 +- test/Actions/EditGoalieSpec.hs | 32 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 9d3dae9..6964978 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -81,7 +81,7 @@ editGoalieYtdWins -- ^ The number of wins -> ProgState -> ProgState -editGoalieYtdWins = undefined +editGoalieYtdWins wins = editGoalie (gYtd.gsWins .~ wins) EGYtd editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do diff --git a/test/Actions/EditGoalieSpec.hs b/test/Actions/EditGoalieSpec.hs index d407466..3a788f7 100644 --- a/test/Actions/EditGoalieSpec.hs +++ b/test/Actions/EditGoalieSpec.hs @@ -36,6 +36,7 @@ spec = describe "EditGoalie" $ do editGoalieYtdGamesSpec editGoalieYtdMinsSpec editGoalieYtdGoalsSpec + editGoalieYtdWinsSpec editGoalieNumberSpec :: Spec editGoalieNumberSpec = describe "editGoalieNumber" $ editTest @@ -192,6 +193,37 @@ editGoalieYtdGoalsSpec = describe "editGoalieYtdGoals" $ editTest ) ] +editGoalieYtdWinsSpec :: Spec +editGoalieYtdWinsSpec = describe "editGoalieYtdWins" $ editTest + (editGoalieYtdWins 1) + EGYtdWins + (\(num, name, wins) -> newGoalie num name & gYtd.gsWins .~ wins) + [ ( "set Joe" + , Just 0 + , ( 2, "Joe", 1 ) + , ( 3, "Bob", 0 ) + , EGYtd + ) + , ( "set Bob" + , Just 1 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 1 ) + , EGYtd + ) + , ( "out of bounds" + , Just 2 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGYtdWins + ) + , ( "no goalie selected" + , Nothing + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGYtdWins + ) + ] + editTest :: (ProgState -> ProgState) -> EditGoalieMode From e50861613d4bb4f825bf1c55fd7f8f50ae402bff Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 01:49:22 -0500 Subject: [PATCH 37/61] implemented Mtlstats.Control.EditGoalie.ytdLossesC --- src/Mtlstats/Control/EditGoalie.hs | 2 +- src/Mtlstats/Prompt/EditGoalie.hs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index 1e5f755..89e8f0b 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -91,7 +91,7 @@ ytdWinsC :: Controller ytdWinsC = promptController editGoalieYtdWinsPrompt ytdLossesC :: Controller -ytdLossesC = undefined +ytdLossesC = promptController editGoalieYtdLossesPrompt ytdTiesC :: Controller ytdTiesC = undefined diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index 6a774ba..174f568 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -27,6 +27,7 @@ module Mtlstats.Prompt.EditGoalie , editGoalieYtdMinsPrompt , editGoalieYtdGoalsPrompt , editGoalieYtdWinsPrompt + , editGoalieYtdLossesPrompt ) where import Control.Monad.Trans.State (modify) @@ -70,3 +71,7 @@ editGoalieYtdGoalsPrompt = numPrompt "Year-to-date goals allowed: " $ editGoalieYtdWinsPrompt :: Prompt editGoalieYtdWinsPrompt = numPrompt "Year-to-date wins: " $ modify . editGoalieYtdWins + +-- | Prompt to edit a goalie's YTD losses +editGoalieYtdLossesPrompt :: Prompt +editGoalieYtdLossesPrompt = undefined From 01859634a1b6a00a5d25ab4851d77b36d6dda586 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 01:51:59 -0500 Subject: [PATCH 38/61] implemented editGoalieYtdLossesPrompt --- src/Mtlstats/Actions/EditGoalie.hs | 9 +++++++++ src/Mtlstats/Prompt/EditGoalie.hs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 6964978..84925d5 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -26,6 +26,7 @@ module Mtlstats.Actions.EditGoalie , editGoalieYtdMins , editGoalieYtdGoals , editGoalieYtdWins + , editGoalieYtdLosses ) where import Control.Monad (void) @@ -83,6 +84,14 @@ editGoalieYtdWins -> ProgState editGoalieYtdWins wins = editGoalie (gYtd.gsWins .~ wins) EGYtd +-- | Edits a goalie's YTD losses +editGoalieYtdLosses + :: Int + -- ^ The number of losses + -> ProgState + -> ProgState +editGoalieYtdLosses = undefined + editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do gid <- s^.progMode.editGoalieStateL.egsSelectedGoalie diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index 174f568..34e2bde 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -74,4 +74,5 @@ editGoalieYtdWinsPrompt = numPrompt "Year-to-date wins: " $ -- | Prompt to edit a goalie's YTD losses editGoalieYtdLossesPrompt :: Prompt -editGoalieYtdLossesPrompt = undefined +editGoalieYtdLossesPrompt = numPrompt "Year-to-date losses: " $ + modify . editGoalieYtdLosses From 4655cb37b938e63720181e59787d275958b6a8d3 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 01:57:51 -0500 Subject: [PATCH 39/61] implemented editGoalieYtdLosses --- src/Mtlstats/Actions/EditGoalie.hs | 2 +- test/Actions/EditGoalieSpec.hs | 32 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 84925d5..1417f4d 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -90,7 +90,7 @@ editGoalieYtdLosses -- ^ The number of losses -> ProgState -> ProgState -editGoalieYtdLosses = undefined +editGoalieYtdLosses losses = editGoalie (gYtd.gsLosses .~ losses) EGYtd editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do diff --git a/test/Actions/EditGoalieSpec.hs b/test/Actions/EditGoalieSpec.hs index 3a788f7..13e03ab 100644 --- a/test/Actions/EditGoalieSpec.hs +++ b/test/Actions/EditGoalieSpec.hs @@ -37,6 +37,7 @@ spec = describe "EditGoalie" $ do editGoalieYtdMinsSpec editGoalieYtdGoalsSpec editGoalieYtdWinsSpec + editGoalieYtdLossesSpec editGoalieNumberSpec :: Spec editGoalieNumberSpec = describe "editGoalieNumber" $ editTest @@ -224,6 +225,37 @@ editGoalieYtdWinsSpec = describe "editGoalieYtdWins" $ editTest ) ] +editGoalieYtdLossesSpec :: Spec +editGoalieYtdLossesSpec = describe "editGoalieYtdLosses" $ editTest + (editGoalieYtdLosses 1) + EGYtdLosses + (\(num, name, losses) -> newGoalie num name & gYtd.gsLosses .~ losses) + [ ( "set Joe" + , Just 0 + , ( 2, "Joe", 1 ) + , ( 3, "Bob", 0 ) + , EGYtd + ) + , ( "set Bob" + , Just 1 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 1 ) + , EGYtd + ) + , ( "out of bounds" + , Just 2 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGYtdLosses + ) + , ( "no goalie selected" + , Nothing + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGYtdLosses + ) + ] + editTest :: (ProgState -> ProgState) -> EditGoalieMode From b8aa00aa81ace38c3513dab1e4870f8823c5f78b Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:00:10 -0500 Subject: [PATCH 40/61] implemented Mtlstats.Control.EditGoalie.ytdTiesC --- src/Mtlstats/Control/EditGoalie.hs | 2 +- src/Mtlstats/Prompt/EditGoalie.hs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index 89e8f0b..ad164ae 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -94,7 +94,7 @@ ytdLossesC :: Controller ytdLossesC = promptController editGoalieYtdLossesPrompt ytdTiesC :: Controller -ytdTiesC = undefined +ytdTiesC = promptController editGoalieYtdTiesPrompt ltGamesC :: Controller ltGamesC = undefined diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index 34e2bde..c0158a8 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -28,6 +28,7 @@ module Mtlstats.Prompt.EditGoalie , editGoalieYtdGoalsPrompt , editGoalieYtdWinsPrompt , editGoalieYtdLossesPrompt + , editGoalieYtdTiesPrompt ) where import Control.Monad.Trans.State (modify) @@ -76,3 +77,7 @@ editGoalieYtdWinsPrompt = numPrompt "Year-to-date wins: " $ editGoalieYtdLossesPrompt :: Prompt editGoalieYtdLossesPrompt = numPrompt "Year-to-date losses: " $ modify . editGoalieYtdLosses + +-- | Prompt to edit a goalie's YTD ties +editGoalieYtdTiesPrompt :: Prompt +editGoalieYtdTiesPrompt = undefined From 101f436424a063c25f375b0c2eda0160643887e3 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:02:06 -0500 Subject: [PATCH 41/61] implemented editGoalieYtdTiesPrompt --- src/Mtlstats/Actions/EditGoalie.hs | 9 +++++++++ src/Mtlstats/Prompt/EditGoalie.hs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 1417f4d..4615411 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -27,6 +27,7 @@ module Mtlstats.Actions.EditGoalie , editGoalieYtdGoals , editGoalieYtdWins , editGoalieYtdLosses + , editGoalieYtdTies ) where import Control.Monad (void) @@ -92,6 +93,14 @@ editGoalieYtdLosses -> ProgState editGoalieYtdLosses losses = editGoalie (gYtd.gsLosses .~ losses) EGYtd +-- | Edits a goalie's YTD ties +editGoalieYtdTies + :: Int + -- ^ The number of ties + -> ProgState + -> ProgState +editGoalieYtdTies = undefined + editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do gid <- s^.progMode.editGoalieStateL.egsSelectedGoalie diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index c0158a8..d3e6ea4 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -80,4 +80,5 @@ editGoalieYtdLossesPrompt = numPrompt "Year-to-date losses: " $ -- | Prompt to edit a goalie's YTD ties editGoalieYtdTiesPrompt :: Prompt -editGoalieYtdTiesPrompt = undefined +editGoalieYtdTiesPrompt = numPrompt "Year-to-date ties: " $ + modify . editGoalieYtdTies From f97db477ddd8e848c880d95dd0de7ed1e32ec93c Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:07:00 -0500 Subject: [PATCH 42/61] implemented editGoalieYtdTies --- src/Mtlstats/Actions/EditGoalie.hs | 2 +- test/Actions/EditGoalieSpec.hs | 32 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 4615411..cb0f129 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -99,7 +99,7 @@ editGoalieYtdTies -- ^ The number of ties -> ProgState -> ProgState -editGoalieYtdTies = undefined +editGoalieYtdTies ties = editGoalie (gYtd.gsTies .~ ties) EGYtd editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do diff --git a/test/Actions/EditGoalieSpec.hs b/test/Actions/EditGoalieSpec.hs index 13e03ab..ac92d2e 100644 --- a/test/Actions/EditGoalieSpec.hs +++ b/test/Actions/EditGoalieSpec.hs @@ -38,6 +38,7 @@ spec = describe "EditGoalie" $ do editGoalieYtdGoalsSpec editGoalieYtdWinsSpec editGoalieYtdLossesSpec + editGoalieYtdTiesSpec editGoalieNumberSpec :: Spec editGoalieNumberSpec = describe "editGoalieNumber" $ editTest @@ -256,6 +257,37 @@ editGoalieYtdLossesSpec = describe "editGoalieYtdLosses" $ editTest ) ] +editGoalieYtdTiesSpec :: Spec +editGoalieYtdTiesSpec = describe "editGoalieYtdTies" $ editTest + (editGoalieYtdTies 1) + EGYtdTies + (\(num, name, ties) -> newGoalie num name & gYtd.gsTies .~ ties) + [ ( "set Joe" + , Just 0 + , ( 2, "Joe", 1 ) + , ( 3, "Bob", 0 ) + , EGYtd + ) + , ( "set Bob" + , Just 1 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 1 ) + , EGYtd + ) + , ( "out of bounds" + , Just 2 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGYtdTies + ) + , ( "no goalie selected" + , Nothing + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGYtdTies + ) + ] + editTest :: (ProgState -> ProgState) -> EditGoalieMode From 8c482ae785b3c6b03e1cae0f2a584cca7da2f7d8 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:09:20 -0500 Subject: [PATCH 43/61] implemented Mtlstats.Control.EditGoalie.ltGamesC --- src/Mtlstats/Control/EditGoalie.hs | 2 +- src/Mtlstats/Prompt/EditGoalie.hs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index ad164ae..a4a9f3a 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -97,7 +97,7 @@ ytdTiesC :: Controller ytdTiesC = promptController editGoalieYtdTiesPrompt ltGamesC :: Controller -ltGamesC = undefined +ltGamesC = promptController editGoalieLtGamesPrompt ltMinsC :: Controller ltMinsC = undefined diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index d3e6ea4..21788f4 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -29,6 +29,7 @@ module Mtlstats.Prompt.EditGoalie , editGoalieYtdWinsPrompt , editGoalieYtdLossesPrompt , editGoalieYtdTiesPrompt + , editGoalieLtGamesPrompt ) where import Control.Monad.Trans.State (modify) @@ -82,3 +83,7 @@ editGoalieYtdLossesPrompt = numPrompt "Year-to-date losses: " $ editGoalieYtdTiesPrompt :: Prompt editGoalieYtdTiesPrompt = numPrompt "Year-to-date ties: " $ modify . editGoalieYtdTies + +-- | Prompt to edit a goalie's lifetime games played +editGoalieLtGamesPrompt :: Prompt +editGoalieLtGamesPrompt = undefined From 6b1aa85010b4148c51644f861fc3c812bfb2cf47 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:11:35 -0500 Subject: [PATCH 44/61] implemented editGoalieLtGamesPrompt --- src/Mtlstats/Actions/EditGoalie.hs | 9 +++++++++ src/Mtlstats/Prompt/EditGoalie.hs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index cb0f129..b22002a 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -28,6 +28,7 @@ module Mtlstats.Actions.EditGoalie , editGoalieYtdWins , editGoalieYtdLosses , editGoalieYtdTies + , editGoalieLtGames ) where import Control.Monad (void) @@ -101,6 +102,14 @@ editGoalieYtdTies -> ProgState editGoalieYtdTies ties = editGoalie (gYtd.gsTies .~ ties) EGYtd +-- | Edits a goalie's lifetime games played +editGoalieLtGames + :: Int + -- ^ The number of games + -> ProgState + -> ProgState +editGoalieLtGames = undefined + editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do gid <- s^.progMode.editGoalieStateL.egsSelectedGoalie diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index 21788f4..e3b82c0 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -86,4 +86,5 @@ editGoalieYtdTiesPrompt = numPrompt "Year-to-date ties: " $ -- | Prompt to edit a goalie's lifetime games played editGoalieLtGamesPrompt :: Prompt -editGoalieLtGamesPrompt = undefined +editGoalieLtGamesPrompt = numPrompt "Lifetime games played: " $ + modify . editGoalieLtGames From afdb7653cda877595e8df6ce56b426e60dadb146 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:17:13 -0500 Subject: [PATCH 45/61] implemented editGoalieLtGames --- src/Mtlstats/Actions/EditGoalie.hs | 2 +- test/Actions/EditGoalieSpec.hs | 32 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index b22002a..63fd6ed 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -108,7 +108,7 @@ editGoalieLtGames -- ^ The number of games -> ProgState -> ProgState -editGoalieLtGames = undefined +editGoalieLtGames games = editGoalie (gLifetime.gsGames .~ games) EGLifetime editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do diff --git a/test/Actions/EditGoalieSpec.hs b/test/Actions/EditGoalieSpec.hs index ac92d2e..e3eabfe 100644 --- a/test/Actions/EditGoalieSpec.hs +++ b/test/Actions/EditGoalieSpec.hs @@ -39,6 +39,7 @@ spec = describe "EditGoalie" $ do editGoalieYtdWinsSpec editGoalieYtdLossesSpec editGoalieYtdTiesSpec + editGoalieLtGamesSpec editGoalieNumberSpec :: Spec editGoalieNumberSpec = describe "editGoalieNumber" $ editTest @@ -288,6 +289,37 @@ editGoalieYtdTiesSpec = describe "editGoalieYtdTies" $ editTest ) ] +editGoalieLtGamesSpec :: Spec +editGoalieLtGamesSpec = describe "editGoalieLtGames" $ editTest + (editGoalieLtGames 1) + EGLtGames + (\(num, name, games) -> newGoalie num name & gLifetime.gsGames .~ games) + [ ( "set Joe" + , Just 0 + , ( 2, "Joe", 1 ) + , ( 3, "Bob", 0 ) + , EGLifetime + ) + , ( "set Bob" + , Just 1 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 1 ) + , EGLifetime + ) + , ( "out of bounds" + , Just 2 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGLtGames + ) + , ( "no goalie selected" + , Nothing + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGLtGames + ) + ] + editTest :: (ProgState -> ProgState) -> EditGoalieMode From 52d412942a79d5831dd40e67c7ee0f43ef1bf055 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:19:28 -0500 Subject: [PATCH 46/61] implemented Mtlstats.Control.EditGoalie.ltMinsC --- src/Mtlstats/Control/EditGoalie.hs | 2 +- src/Mtlstats/Prompt/EditGoalie.hs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index a4a9f3a..8ed140d 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -100,7 +100,7 @@ ltGamesC :: Controller ltGamesC = promptController editGoalieLtGamesPrompt ltMinsC :: Controller -ltMinsC = undefined +ltMinsC = promptController editGoalieLtMinsPrompt ltGoalsC :: Controller ltGoalsC = undefined diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index e3b82c0..d473514 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -30,6 +30,7 @@ module Mtlstats.Prompt.EditGoalie , editGoalieYtdLossesPrompt , editGoalieYtdTiesPrompt , editGoalieLtGamesPrompt + , editGoalieLtMinsPrompt ) where import Control.Monad.Trans.State (modify) @@ -88,3 +89,7 @@ editGoalieYtdTiesPrompt = numPrompt "Year-to-date ties: " $ editGoalieLtGamesPrompt :: Prompt editGoalieLtGamesPrompt = numPrompt "Lifetime games played: " $ modify . editGoalieLtGames + +-- | Prompt to edit a goalie's lifetime minutes played +editGoalieLtMinsPrompt :: Prompt +editGoalieLtMinsPrompt = undefined From 30cfea05036084c5d467bff426e74bbc9456188a Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:21:39 -0500 Subject: [PATCH 47/61] implemented editGoalieLtMinsPrompt --- src/Mtlstats/Actions/EditGoalie.hs | 9 +++++++++ src/Mtlstats/Prompt/EditGoalie.hs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 63fd6ed..94495a4 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -29,6 +29,7 @@ module Mtlstats.Actions.EditGoalie , editGoalieYtdLosses , editGoalieYtdTies , editGoalieLtGames + , editGoalieLtMins ) where import Control.Monad (void) @@ -110,6 +111,14 @@ editGoalieLtGames -> ProgState editGoalieLtGames games = editGoalie (gLifetime.gsGames .~ games) EGLifetime +-- | Edits a goalie's lifetime minutes played +editGoalieLtMins + :: Int + -- ^ The number of minutes + -> ProgState + -> ProgState +editGoalieLtMins = undefined + editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do gid <- s^.progMode.editGoalieStateL.egsSelectedGoalie diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index d473514..1181ed0 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -92,4 +92,5 @@ editGoalieLtGamesPrompt = numPrompt "Lifetime games played: " $ -- | Prompt to edit a goalie's lifetime minutes played editGoalieLtMinsPrompt :: Prompt -editGoalieLtMinsPrompt = undefined +editGoalieLtMinsPrompt = numPrompt "Lifetime minutes played: " $ + modify . editGoalieLtMins From 3a1480115d0caf07ea16a9f6b8b69d51f4aebb49 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:26:55 -0500 Subject: [PATCH 48/61] implemented editGoalieLtMins --- src/Mtlstats/Actions/EditGoalie.hs | 2 +- test/Actions/EditGoalieSpec.hs | 32 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 94495a4..3a16443 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -117,7 +117,7 @@ editGoalieLtMins -- ^ The number of minutes -> ProgState -> ProgState -editGoalieLtMins = undefined +editGoalieLtMins mins = editGoalie (gLifetime.gsMinsPlayed .~ mins) EGLifetime editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do diff --git a/test/Actions/EditGoalieSpec.hs b/test/Actions/EditGoalieSpec.hs index e3eabfe..bee64b3 100644 --- a/test/Actions/EditGoalieSpec.hs +++ b/test/Actions/EditGoalieSpec.hs @@ -40,6 +40,7 @@ spec = describe "EditGoalie" $ do editGoalieYtdLossesSpec editGoalieYtdTiesSpec editGoalieLtGamesSpec + editGoalieLtMinsSpec editGoalieNumberSpec :: Spec editGoalieNumberSpec = describe "editGoalieNumber" $ editTest @@ -320,6 +321,37 @@ editGoalieLtGamesSpec = describe "editGoalieLtGames" $ editTest ) ] +editGoalieLtMinsSpec :: Spec +editGoalieLtMinsSpec = describe "editGoalieLtMins" $ editTest + (editGoalieLtMins 1) + EGLtMins + (\(num, name, mins) -> newGoalie num name & gLifetime.gsMinsPlayed .~ mins) + [ ( "set Joe" + , Just 0 + , ( 2, "Joe", 1 ) + , ( 3, "Bob", 0 ) + , EGLifetime + ) + , ( "set Bob" + , Just 1 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 1 ) + , EGLifetime + ) + , ( "out of bounds" + , Just 2 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGLtMins + ) + , ( "no goalie selected" + , Nothing + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGLtMins + ) + ] + editTest :: (ProgState -> ProgState) -> EditGoalieMode From 846d0344350c2a50864f37cf2483da5d9fa26ebe Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:28:53 -0500 Subject: [PATCH 49/61] implemented Mtlstats.Control.EditGoalie.ltGoalsC --- src/Mtlstats/Control/EditGoalie.hs | 2 +- src/Mtlstats/Prompt/EditGoalie.hs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index 8ed140d..229b6ac 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -103,7 +103,7 @@ ltMinsC :: Controller ltMinsC = promptController editGoalieLtMinsPrompt ltGoalsC :: Controller -ltGoalsC = undefined +ltGoalsC = promptController editGoalieLtGoalsPrompt ltWinsC :: Controller ltWinsC = undefined diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index 1181ed0..8e17341 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -31,6 +31,7 @@ module Mtlstats.Prompt.EditGoalie , editGoalieYtdTiesPrompt , editGoalieLtGamesPrompt , editGoalieLtMinsPrompt + , editGoalieLtGoalsPrompt ) where import Control.Monad.Trans.State (modify) @@ -94,3 +95,7 @@ editGoalieLtGamesPrompt = numPrompt "Lifetime games played: " $ editGoalieLtMinsPrompt :: Prompt editGoalieLtMinsPrompt = numPrompt "Lifetime minutes played: " $ modify . editGoalieLtMins + +-- | Prompt to edit a goalie's lifetime goals allowed +editGoalieLtGoalsPrompt :: Prompt +editGoalieLtGoalsPrompt = undefined From c0386fa0b95355aafdf85c21a328fa77d5d29aff Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:31:11 -0500 Subject: [PATCH 50/61] implemented editGoalieLtGoalsPrompt --- src/Mtlstats/Actions/EditGoalie.hs | 9 +++++++++ src/Mtlstats/Prompt/EditGoalie.hs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 3a16443..99598fc 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -30,6 +30,7 @@ module Mtlstats.Actions.EditGoalie , editGoalieYtdTies , editGoalieLtGames , editGoalieLtMins + , editGoalieLtGoals ) where import Control.Monad (void) @@ -119,6 +120,14 @@ editGoalieLtMins -> ProgState editGoalieLtMins mins = editGoalie (gLifetime.gsMinsPlayed .~ mins) EGLifetime +-- | Edits a goalie's lifetime goals allowed +editGoalieLtGoals + :: Int + -- ^ The number of goals + -> ProgState + -> ProgState +editGoalieLtGoals = undefined + editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do gid <- s^.progMode.editGoalieStateL.egsSelectedGoalie diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index 8e17341..2ba1b1c 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -98,4 +98,5 @@ editGoalieLtMinsPrompt = numPrompt "Lifetime minutes played: " $ -- | Prompt to edit a goalie's lifetime goals allowed editGoalieLtGoalsPrompt :: Prompt -editGoalieLtGoalsPrompt = undefined +editGoalieLtGoalsPrompt = numPrompt "Lifetime goals allowed: " $ + modify . editGoalieLtGoals From 954fe98998a0bec409edb808f1f5c2d13ad477c7 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:35:58 -0500 Subject: [PATCH 51/61] implemented editGoalieLtGoals --- src/Mtlstats/Actions/EditGoalie.hs | 2 +- test/Actions/EditGoalieSpec.hs | 32 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 99598fc..18b0597 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -126,7 +126,7 @@ editGoalieLtGoals -- ^ The number of goals -> ProgState -> ProgState -editGoalieLtGoals = undefined +editGoalieLtGoals goals = editGoalie (gLifetime.gsGoalsAllowed .~ goals) EGLifetime editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do diff --git a/test/Actions/EditGoalieSpec.hs b/test/Actions/EditGoalieSpec.hs index bee64b3..dc63adf 100644 --- a/test/Actions/EditGoalieSpec.hs +++ b/test/Actions/EditGoalieSpec.hs @@ -41,6 +41,7 @@ spec = describe "EditGoalie" $ do editGoalieYtdTiesSpec editGoalieLtGamesSpec editGoalieLtMinsSpec + editGoalieLtGoalsSpec editGoalieNumberSpec :: Spec editGoalieNumberSpec = describe "editGoalieNumber" $ editTest @@ -352,6 +353,37 @@ editGoalieLtMinsSpec = describe "editGoalieLtMins" $ editTest ) ] +editGoalieLtGoalsSpec :: Spec +editGoalieLtGoalsSpec = describe "editGoalieLtGoals" $ editTest + (editGoalieLtGoals 1) + EGLtGoals + (\(num, name, goals) -> newGoalie num name & gLifetime.gsGoalsAllowed .~ goals) + [ ( "set Joe" + , Just 0 + , ( 2, "Joe", 1 ) + , ( 3, "Bob", 0 ) + , EGLifetime + ) + , ( "set Bob" + , Just 1 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 1 ) + , EGLifetime + ) + , ( "out of bounds" + , Just 2 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGLtGoals + ) + , ( "no goalie selected" + , Nothing + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGLtGoals + ) + ] + editTest :: (ProgState -> ProgState) -> EditGoalieMode From 13acbbdf355feef5870711244d1f0509e17f9535 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:38:08 -0500 Subject: [PATCH 52/61] implemented Mtlstats.Control.EditGoalie.ltWinsC --- src/Mtlstats/Control/EditGoalie.hs | 2 +- src/Mtlstats/Prompt/EditGoalie.hs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index 229b6ac..9960a18 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -106,7 +106,7 @@ ltGoalsC :: Controller ltGoalsC = promptController editGoalieLtGoalsPrompt ltWinsC :: Controller -ltWinsC = undefined +ltWinsC = promptController editGoalieLtWinsPrompt ltLossesC :: Controller ltLossesC = undefined diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index 2ba1b1c..c82f1b0 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -32,6 +32,7 @@ module Mtlstats.Prompt.EditGoalie , editGoalieLtGamesPrompt , editGoalieLtMinsPrompt , editGoalieLtGoalsPrompt + , editGoalieLtWinsPrompt ) where import Control.Monad.Trans.State (modify) @@ -100,3 +101,7 @@ editGoalieLtMinsPrompt = numPrompt "Lifetime minutes played: " $ editGoalieLtGoalsPrompt :: Prompt editGoalieLtGoalsPrompt = numPrompt "Lifetime goals allowed: " $ modify . editGoalieLtGoals + +-- | Prompt to edit a goalie's lifetime wins +editGoalieLtWinsPrompt :: Prompt +editGoalieLtWinsPrompt = undefined From dd34429f59fd4a34a951db3befd547a5b57384d4 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:40:01 -0500 Subject: [PATCH 53/61] implemented editGoalieLtWinsPrompt --- src/Mtlstats/Actions/EditGoalie.hs | 9 +++++++++ src/Mtlstats/Prompt/EditGoalie.hs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 18b0597..be00d1a 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -31,6 +31,7 @@ module Mtlstats.Actions.EditGoalie , editGoalieLtGames , editGoalieLtMins , editGoalieLtGoals + , editGoalieLtWins ) where import Control.Monad (void) @@ -128,6 +129,14 @@ editGoalieLtGoals -> ProgState editGoalieLtGoals goals = editGoalie (gLifetime.gsGoalsAllowed .~ goals) EGLifetime +-- | Edits a goalie's lifetime wins +editGoalieLtWins + :: Int + -- ^ The number of wins + -> ProgState + -> ProgState +editGoalieLtWins = undefined + editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do gid <- s^.progMode.editGoalieStateL.egsSelectedGoalie diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index c82f1b0..23403fb 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -104,4 +104,5 @@ editGoalieLtGoalsPrompt = numPrompt "Lifetime goals allowed: " $ -- | Prompt to edit a goalie's lifetime wins editGoalieLtWinsPrompt :: Prompt -editGoalieLtWinsPrompt = undefined +editGoalieLtWinsPrompt = numPrompt "Lifetime wins: " $ + modify . editGoalieLtWins From 2860309fc5d3402e31c014c04180f616e95a2eea Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:45:31 -0500 Subject: [PATCH 54/61] implemented editGoalieLtWins --- src/Mtlstats/Actions/EditGoalie.hs | 2 +- test/Actions/EditGoalieSpec.hs | 32 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index be00d1a..932df4d 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -135,7 +135,7 @@ editGoalieLtWins -- ^ The number of wins -> ProgState -> ProgState -editGoalieLtWins = undefined +editGoalieLtWins wins = editGoalie (gLifetime.gsWins .~ wins) EGLifetime editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do diff --git a/test/Actions/EditGoalieSpec.hs b/test/Actions/EditGoalieSpec.hs index dc63adf..dd75b10 100644 --- a/test/Actions/EditGoalieSpec.hs +++ b/test/Actions/EditGoalieSpec.hs @@ -42,6 +42,7 @@ spec = describe "EditGoalie" $ do editGoalieLtGamesSpec editGoalieLtMinsSpec editGoalieLtGoalsSpec + editGoalieLtWinsSpec editGoalieNumberSpec :: Spec editGoalieNumberSpec = describe "editGoalieNumber" $ editTest @@ -384,6 +385,37 @@ editGoalieLtGoalsSpec = describe "editGoalieLtGoals" $ editTest ) ] +editGoalieLtWinsSpec :: Spec +editGoalieLtWinsSpec = describe "editGoalieLtWins" $ editTest + (editGoalieLtWins 1) + EGLtWins + (\(num, name, wins) -> newGoalie num name & gLifetime.gsWins .~ wins) + [ ( "set Joe" + , Just 0 + , ( 2, "Joe", 1 ) + , ( 3, "Bob", 0 ) + , EGLifetime + ) + , ( "set Bob" + , Just 1 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 1 ) + , EGLifetime + ) + , ( "out of bounds" + , Just 2 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGLtWins + ) + , ( "no goalie selected" + , Nothing + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGLtWins + ) + ] + editTest :: (ProgState -> ProgState) -> EditGoalieMode From ac3b8e9522a2bef3da71477beacb0faac36a4f2e Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:47:57 -0500 Subject: [PATCH 55/61] implemented Mtlstats.Control.EditGoalie.ltLossesC --- src/Mtlstats/Control/EditGoalie.hs | 2 +- src/Mtlstats/Prompt/EditGoalie.hs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index 9960a18..ae882ca 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -109,7 +109,7 @@ ltWinsC :: Controller ltWinsC = promptController editGoalieLtWinsPrompt ltLossesC :: Controller -ltLossesC = undefined +ltLossesC = promptController editGoalieLtLossesPrompt ltTiesC :: Controller ltTiesC = undefined diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index 23403fb..44f8602 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -33,6 +33,7 @@ module Mtlstats.Prompt.EditGoalie , editGoalieLtMinsPrompt , editGoalieLtGoalsPrompt , editGoalieLtWinsPrompt + , editGoalieLtLossesPrompt ) where import Control.Monad.Trans.State (modify) @@ -106,3 +107,7 @@ editGoalieLtGoalsPrompt = numPrompt "Lifetime goals allowed: " $ editGoalieLtWinsPrompt :: Prompt editGoalieLtWinsPrompt = numPrompt "Lifetime wins: " $ modify . editGoalieLtWins + +-- | Prompt to edit a goalie's lifetime losses +editGoalieLtLossesPrompt :: Prompt +editGoalieLtLossesPrompt = undefined From 3ba3875752586683293cf09f8010df796c23aae2 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:49:55 -0500 Subject: [PATCH 56/61] implemented editGoalieLtLossesPrompt --- src/Mtlstats/Actions/EditGoalie.hs | 9 +++++++++ src/Mtlstats/Prompt/EditGoalie.hs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 932df4d..bdab0c4 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -32,6 +32,7 @@ module Mtlstats.Actions.EditGoalie , editGoalieLtMins , editGoalieLtGoals , editGoalieLtWins + , editGoalieLtLosses ) where import Control.Monad (void) @@ -137,6 +138,14 @@ editGoalieLtWins -> ProgState editGoalieLtWins wins = editGoalie (gLifetime.gsWins .~ wins) EGLifetime +-- | Edits a goalie's lifetime losses +editGoalieLtLosses + :: Int + -- ^ The number of losses + -> ProgState + -> ProgState +editGoalieLtLosses = undefined + editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do gid <- s^.progMode.editGoalieStateL.egsSelectedGoalie diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index 44f8602..843e63e 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -110,4 +110,5 @@ editGoalieLtWinsPrompt = numPrompt "Lifetime wins: " $ -- | Prompt to edit a goalie's lifetime losses editGoalieLtLossesPrompt :: Prompt -editGoalieLtLossesPrompt = undefined +editGoalieLtLossesPrompt = numPrompt "Lifetime losses: " $ + modify . editGoalieLtLosses From 945610293552813234430d4e3c53ab8aa10d0083 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:53:26 -0500 Subject: [PATCH 57/61] implemented editGoalieLtLosses --- src/Mtlstats/Actions/EditGoalie.hs | 2 +- test/Actions/EditGoalieSpec.hs | 32 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index bdab0c4..e7b2752 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -144,7 +144,7 @@ editGoalieLtLosses -- ^ The number of losses -> ProgState -> ProgState -editGoalieLtLosses = undefined +editGoalieLtLosses losses = editGoalie (gLifetime.gsLosses .~ losses) EGLifetime editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do diff --git a/test/Actions/EditGoalieSpec.hs b/test/Actions/EditGoalieSpec.hs index dd75b10..97e710d 100644 --- a/test/Actions/EditGoalieSpec.hs +++ b/test/Actions/EditGoalieSpec.hs @@ -43,6 +43,7 @@ spec = describe "EditGoalie" $ do editGoalieLtMinsSpec editGoalieLtGoalsSpec editGoalieLtWinsSpec + editGoalieLtLossesSpec editGoalieNumberSpec :: Spec editGoalieNumberSpec = describe "editGoalieNumber" $ editTest @@ -416,6 +417,37 @@ editGoalieLtWinsSpec = describe "editGoalieLtWins" $ editTest ) ] +editGoalieLtLossesSpec :: Spec +editGoalieLtLossesSpec = describe "editGoalieLtLosses" $ editTest + (editGoalieLtLosses 1) + EGLtLosses + (\(num, name, losses) -> newGoalie num name & gLifetime.gsLosses .~ losses) + [ ( "set Joe" + , Just 0 + , ( 2, "Joe", 1 ) + , ( 3, "Bob", 0 ) + , EGLifetime + ) + , ( "set Bob" + , Just 1 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 1 ) + , EGLifetime + ) + , ( "out of bounds" + , Just 2 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGLtLosses + ) + , ( "no goalie selected" + , Nothing + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGLtLosses + ) + ] + editTest :: (ProgState -> ProgState) -> EditGoalieMode From aac2752e9515f1a9260f6a87da9af4116e88e502 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:55:50 -0500 Subject: [PATCH 58/61] implemented Mtlstats.Control.EditGoalie.ltTiesC --- src/Mtlstats/Control/EditGoalie.hs | 2 +- src/Mtlstats/Prompt/EditGoalie.hs | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Control/EditGoalie.hs b/src/Mtlstats/Control/EditGoalie.hs index ae882ca..094ac09 100644 --- a/src/Mtlstats/Control/EditGoalie.hs +++ b/src/Mtlstats/Control/EditGoalie.hs @@ -112,7 +112,7 @@ ltLossesC :: Controller ltLossesC = promptController editGoalieLtLossesPrompt ltTiesC :: Controller -ltTiesC = undefined +ltTiesC = promptController editGoalieLtTiesPrompt header :: ProgState -> C.Update () header s = C.drawString $ fromMaybe "" $ do diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index 843e63e..7d69d1e 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -34,6 +34,7 @@ module Mtlstats.Prompt.EditGoalie , editGoalieLtGoalsPrompt , editGoalieLtWinsPrompt , editGoalieLtLossesPrompt + , editGoalieLtTiesPrompt ) where import Control.Monad.Trans.State (modify) @@ -112,3 +113,7 @@ editGoalieLtWinsPrompt = numPrompt "Lifetime wins: " $ editGoalieLtLossesPrompt :: Prompt editGoalieLtLossesPrompt = numPrompt "Lifetime losses: " $ modify . editGoalieLtLosses + +-- | Prompt to edit a goalie's lifetime ties +editGoalieLtTiesPrompt :: Prompt +editGoalieLtTiesPrompt = undefined From 61d788cb4ea6beca78e816b1cf8ef8f43e4c3994 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 02:57:56 -0500 Subject: [PATCH 59/61] implemented editGoalieLtTiesPrompt --- src/Mtlstats/Actions/EditGoalie.hs | 9 +++++++++ src/Mtlstats/Prompt/EditGoalie.hs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index e7b2752..1cd8364 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -33,6 +33,7 @@ module Mtlstats.Actions.EditGoalie , editGoalieLtGoals , editGoalieLtWins , editGoalieLtLosses + , editGoalieLtTies ) where import Control.Monad (void) @@ -146,6 +147,14 @@ editGoalieLtLosses -> ProgState editGoalieLtLosses losses = editGoalie (gLifetime.gsLosses .~ losses) EGLifetime +-- | Edits a goalie's lifetime ties +editGoalieLtTies + :: Int + -- ^ The number of ties + -> ProgState + -> ProgState +editGoalieLtTies = undefined + editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do gid <- s^.progMode.editGoalieStateL.egsSelectedGoalie diff --git a/src/Mtlstats/Prompt/EditGoalie.hs b/src/Mtlstats/Prompt/EditGoalie.hs index 7d69d1e..fdec636 100644 --- a/src/Mtlstats/Prompt/EditGoalie.hs +++ b/src/Mtlstats/Prompt/EditGoalie.hs @@ -116,4 +116,5 @@ editGoalieLtLossesPrompt = numPrompt "Lifetime losses: " $ -- | Prompt to edit a goalie's lifetime ties editGoalieLtTiesPrompt :: Prompt -editGoalieLtTiesPrompt = undefined +editGoalieLtTiesPrompt = numPrompt "Lifetime ties: " $ + modify . editGoalieLtTies From 5b9c18730cc0408e687d91ba931b4f91369c6d40 Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 03:02:27 -0500 Subject: [PATCH 60/61] implemented editGoalieLtTies --- src/Mtlstats/Actions/EditGoalie.hs | 2 +- test/Actions/EditGoalieSpec.hs | 32 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Mtlstats/Actions/EditGoalie.hs b/src/Mtlstats/Actions/EditGoalie.hs index 1cd8364..c1599b2 100644 --- a/src/Mtlstats/Actions/EditGoalie.hs +++ b/src/Mtlstats/Actions/EditGoalie.hs @@ -153,7 +153,7 @@ editGoalieLtTies -- ^ The number of ties -> ProgState -> ProgState -editGoalieLtTies = undefined +editGoalieLtTies ties = editGoalie (gLifetime.gsTies .~ ties) EGLifetime editGoalie :: (Goalie -> Goalie) -> EditGoalieMode -> ProgState -> ProgState editGoalie f mode s = fromMaybe s $ do diff --git a/test/Actions/EditGoalieSpec.hs b/test/Actions/EditGoalieSpec.hs index 97e710d..af8c4bb 100644 --- a/test/Actions/EditGoalieSpec.hs +++ b/test/Actions/EditGoalieSpec.hs @@ -44,6 +44,7 @@ spec = describe "EditGoalie" $ do editGoalieLtGoalsSpec editGoalieLtWinsSpec editGoalieLtLossesSpec + editGoalieLtTiesSpec editGoalieNumberSpec :: Spec editGoalieNumberSpec = describe "editGoalieNumber" $ editTest @@ -448,6 +449,37 @@ editGoalieLtLossesSpec = describe "editGoalieLtLosses" $ editTest ) ] +editGoalieLtTiesSpec :: Spec +editGoalieLtTiesSpec = describe "editGoalieLtTies" $ editTest + (editGoalieLtTies 1) + EGLtTies + (\(num, name, ties) -> newGoalie num name & gLifetime.gsTies .~ ties) + [ ( "set Joe" + , Just 0 + , ( 2, "Joe", 1 ) + , ( 3, "Bob", 0 ) + , EGLifetime + ) + , ( "set Bob" + , Just 1 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 1 ) + , EGLifetime + ) + , ( "out of bounds" + , Just 2 + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGLtTies + ) + , ( "no goalie selected" + , Nothing + , ( 2, "Joe", 0 ) + , ( 3, "Bob", 0 ) + , EGLtTies + ) + ] + editTest :: (ProgState -> ProgState) -> EditGoalieMode From 29ae55a01ed4ef544f8a3428b41bf47a3eec7dfb Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Thu, 14 Nov 2019 03:08:04 -0500 Subject: [PATCH 61/61] updated change log --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index 03aa9e9..5952c9a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,7 @@ ## current - Generate lifetime statistics report +- Implemented goalie editing ## 0.5.0