removed setHomeGame and setAwayGame
made redundant by gameTypeL
This commit is contained in:
parent
02f04a3d6c
commit
923c143826
|
@ -19,14 +19,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
|
||||
-}
|
||||
|
||||
{-# LANGUAGE LambdaCase #-}
|
||||
|
||||
module Mtlstats.Actions
|
||||
( startNewSeason
|
||||
, resetYtd
|
||||
, startNewGame
|
||||
, setHomeGame
|
||||
, setAwayGame
|
||||
) where
|
||||
|
||||
import Lens.Micro (over, (&), (.~), (?~), (%~))
|
||||
|
@ -48,15 +44,3 @@ startNewGame :: ProgState -> ProgState
|
|||
startNewGame
|
||||
= (progMode .~ NewGame newGameState)
|
||||
. (database . dbGames %~ succ)
|
||||
|
||||
-- | Sets the game type to 'HomeGame'
|
||||
setHomeGame :: ProgState -> ProgState
|
||||
setHomeGame = over progMode $ \case
|
||||
NewGame gs -> NewGame (gs & gameType ?~ HomeGame)
|
||||
_ -> NewGame $ newGameState & gameType ?~ HomeGame
|
||||
|
||||
-- | Sets the game type to 'AwayGame'
|
||||
setAwayGame :: ProgState -> ProgState
|
||||
setAwayGame = over progMode $ \case
|
||||
NewGame gs -> NewGame (gs & gameType ?~ AwayGame)
|
||||
_ -> NewGame $ newGameState & gameType ?~ AwayGame
|
||||
|
|
|
@ -30,7 +30,7 @@ module Mtlstats.Menu (
|
|||
) where
|
||||
|
||||
import Control.Monad.Trans.State (modify)
|
||||
import Lens.Micro ((^.), (.~))
|
||||
import Lens.Micro ((^.), (.~), (?~))
|
||||
import qualified UI.NCurses as C
|
||||
|
||||
import Mtlstats.Actions
|
||||
|
@ -73,7 +73,7 @@ newSeasonMenu = Menu "*** SEASON TYPE ***" ()
|
|||
gameTypeMenu :: Menu ()
|
||||
gameTypeMenu = Menu "*** GAME TYPE ***" ()
|
||||
[ MenuItem '1' "Home Game" $
|
||||
modify setHomeGame
|
||||
modify $ progMode . gameTypeL ?~ HomeGame
|
||||
, MenuItem '2' "Away Game" $
|
||||
modify setAwayGame
|
||||
modify $ progMode . gameTypeL ?~ AwayGame
|
||||
]
|
||||
|
|
|
@ -34,8 +34,6 @@ spec = describe "Mtlstats.Actions" $ do
|
|||
startNewSeasonSpec
|
||||
startNewGameSpec
|
||||
resetYtdSpec
|
||||
setHomeGameSpec
|
||||
setAwayGameSpec
|
||||
|
||||
startNewSeasonSpec :: Spec
|
||||
startNewSeasonSpec = describe "startNewSeason" $ do
|
||||
|
@ -103,38 +101,6 @@ resetYtdSpec = describe "resetYtd" $
|
|||
lt ^. gsTies `shouldNotBe` 0) $
|
||||
s ^. database . dbGoalies
|
||||
|
||||
setHomeGameSpec :: Spec
|
||||
setHomeGameSpec = describe "setHomeGame" $ do
|
||||
let m = NewGame $ newGameState & gameType ?~ HomeGame
|
||||
|
||||
context "unexpected mode" $
|
||||
it "should set the game type" $ let
|
||||
s = setHomeGame newProgState
|
||||
in s ^. progMode `shouldBe` m
|
||||
|
||||
context "NewGame mode" $
|
||||
it "should set the game type" $ let
|
||||
s = newProgState
|
||||
& progMode .~ NewGame newGameState
|
||||
& setHomeGame
|
||||
in s ^. progMode `shouldBe` m
|
||||
|
||||
setAwayGameSpec :: Spec
|
||||
setAwayGameSpec = describe "setAwayGame" $ do
|
||||
let m = NewGame $ newGameState & gameType ?~ AwayGame
|
||||
|
||||
context "unexpected mode" $
|
||||
it "should set the game type" $ let
|
||||
s = setAwayGame newProgState
|
||||
in s ^. progMode `shouldBe` m
|
||||
|
||||
context "NewGame mode" $
|
||||
it "should set the game type" $ let
|
||||
s = newProgState
|
||||
& progMode .~ NewGame newGameState
|
||||
& setAwayGame
|
||||
in s ^. progMode `shouldBe` m
|
||||
|
||||
makePlayer :: IO Player
|
||||
makePlayer = Player
|
||||
<$> makeNum
|
||||
|
|
Loading…
Reference in New Issue
Block a user