clear rookies on new (regular) season
This commit is contained in:
parent
fcfbcea72f
commit
3b4ce50ae8
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
## current
|
## current
|
||||||
- Added active flag to players/goalies
|
- Added active flag to players/goalies
|
||||||
|
- Clear rookie flag on new (regular) season
|
||||||
|
|
||||||
## 0.10.0
|
## 0.10.0
|
||||||
- Don't show player number zero in reports
|
- Don't show player number zero in reports
|
||||||
|
@ -24,6 +24,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
module Mtlstats.Actions
|
module Mtlstats.Actions
|
||||||
( startNewSeason
|
( startNewSeason
|
||||||
, resetYtd
|
, resetYtd
|
||||||
|
, clearRookies
|
||||||
, resetStandings
|
, resetStandings
|
||||||
, startNewGame
|
, startNewGame
|
||||||
, addChar
|
, addChar
|
||||||
@ -61,6 +62,12 @@ resetYtd
|
|||||||
= (database . dbPlayers %~ map (pYtd .~ newPlayerStats))
|
= (database . dbPlayers %~ map (pYtd .~ newPlayerStats))
|
||||||
. (database . dbGoalies %~ map (gYtd .~ newGoalieStats))
|
. (database . dbGoalies %~ map (gYtd .~ newGoalieStats))
|
||||||
|
|
||||||
|
-- | Clears the rookie flag from all players/goalies
|
||||||
|
clearRookies :: ProgState -> ProgState
|
||||||
|
clearRookies = database
|
||||||
|
%~ (dbPlayers %~ map (pRookie .~ False))
|
||||||
|
. (dbGoalies %~ map (gRookie .~ False))
|
||||||
|
|
||||||
-- | Resets game standings
|
-- | Resets game standings
|
||||||
resetStandings :: ProgState -> ProgState
|
resetStandings :: ProgState -> ProgState
|
||||||
resetStandings = database
|
resetStandings = database
|
||||||
|
@ -131,6 +131,7 @@ newSeasonMenu :: Menu ()
|
|||||||
newSeasonMenu = Menu "*** SEASON TYPE ***" ()
|
newSeasonMenu = Menu "*** SEASON TYPE ***" ()
|
||||||
[ MenuItem 'R' "Regular Season" $ modify
|
[ MenuItem 'R' "Regular Season" $ modify
|
||||||
$ resetYtd
|
$ resetYtd
|
||||||
|
. clearRookies
|
||||||
. resetStandings
|
. resetStandings
|
||||||
. startNewGame
|
. startNewGame
|
||||||
, MenuItem 'P' "Playoffs" $ modify
|
, MenuItem 'P' "Playoffs" $ modify
|
||||||
|
@ -24,7 +24,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
module ActionsSpec (spec) where
|
module ActionsSpec (spec) where
|
||||||
|
|
||||||
import Control.Monad (replicateM)
|
import Control.Monad (replicateM)
|
||||||
import Lens.Micro ((^.), (&), (.~), (?~))
|
import Lens.Micro ((^.), (&), (.~), (?~), (%~))
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
( Spec
|
( Spec
|
||||||
, context
|
, context
|
||||||
@ -46,6 +46,7 @@ spec = describe "Mtlstats.Actions" $ do
|
|||||||
startNewSeasonSpec
|
startNewSeasonSpec
|
||||||
startNewGameSpec
|
startNewGameSpec
|
||||||
resetYtdSpec
|
resetYtdSpec
|
||||||
|
clearRookiesSpec
|
||||||
resetStandingsSpec
|
resetStandingsSpec
|
||||||
addCharSpec
|
addCharSpec
|
||||||
removeCharSpec
|
removeCharSpec
|
||||||
@ -129,6 +130,45 @@ resetYtdSpec = describe "resetYtd" $
|
|||||||
lt ^. gsTies `shouldNotBe` 0) $
|
lt ^. gsTies `shouldNotBe` 0) $
|
||||||
s ^. database . dbGoalies
|
s ^. database . dbGoalies
|
||||||
|
|
||||||
|
clearRookiesSpec :: Spec
|
||||||
|
clearRookiesSpec = describe "clearRookies" $ do
|
||||||
|
let
|
||||||
|
|
||||||
|
players =
|
||||||
|
[ newPlayer 1 "Joe" "centre" & pRookie .~ True
|
||||||
|
, newPlayer 2 "Bob" "centre" & pRookie .~ False
|
||||||
|
]
|
||||||
|
|
||||||
|
goalies =
|
||||||
|
[ newGoalie 3 "Bill" & gRookie .~ True
|
||||||
|
, newGoalie 4 "Doug" & gRookie .~ False
|
||||||
|
]
|
||||||
|
|
||||||
|
ps = newProgState
|
||||||
|
& database
|
||||||
|
%~ (dbPlayers .~ players)
|
||||||
|
. (dbGoalies .~ goalies)
|
||||||
|
|
||||||
|
ps' = clearRookies ps
|
||||||
|
|
||||||
|
context "Players" $ mapM_
|
||||||
|
(\p -> let
|
||||||
|
name = p^.pName
|
||||||
|
rFlag = p^.pRookie
|
||||||
|
in context name $
|
||||||
|
it "should not be a rookie" $
|
||||||
|
rFlag `shouldBe` False)
|
||||||
|
(ps'^.database.dbPlayers)
|
||||||
|
|
||||||
|
context "Goalies" $ mapM_
|
||||||
|
(\g -> let
|
||||||
|
name = g^.gName
|
||||||
|
rFlag = g^.gRookie
|
||||||
|
in context name $
|
||||||
|
it "should not be a rookie" $
|
||||||
|
rFlag `shouldBe` False)
|
||||||
|
(ps'^.database.dbGoalies)
|
||||||
|
|
||||||
resetStandingsSpec :: Spec
|
resetStandingsSpec :: Spec
|
||||||
resetStandingsSpec = describe "resetStandings" $ do
|
resetStandingsSpec = describe "resetStandings" $ do
|
||||||
let
|
let
|
||||||
|
Loading…
x
Reference in New Issue
Block a user