clear rookies on new (regular) season
This commit is contained in:
parent
fcfbcea72f
commit
3b4ce50ae8
|
@ -2,6 +2,7 @@
|
|||
|
||||
## current
|
||||
- Added active flag to players/goalies
|
||||
- Clear rookie flag on new (regular) season
|
||||
|
||||
## 0.10.0
|
||||
- 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
|
||||
( startNewSeason
|
||||
, resetYtd
|
||||
, clearRookies
|
||||
, resetStandings
|
||||
, startNewGame
|
||||
, addChar
|
||||
|
@ -61,6 +62,12 @@ resetYtd
|
|||
= (database . dbPlayers %~ map (pYtd .~ newPlayerStats))
|
||||
. (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
|
||||
resetStandings :: ProgState -> ProgState
|
||||
resetStandings = database
|
||||
|
|
|
@ -131,6 +131,7 @@ newSeasonMenu :: Menu ()
|
|||
newSeasonMenu = Menu "*** SEASON TYPE ***" ()
|
||||
[ MenuItem 'R' "Regular Season" $ modify
|
||||
$ resetYtd
|
||||
. clearRookies
|
||||
. resetStandings
|
||||
. startNewGame
|
||||
, MenuItem 'P' "Playoffs" $ modify
|
||||
|
|
|
@ -24,7 +24,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
module ActionsSpec (spec) where
|
||||
|
||||
import Control.Monad (replicateM)
|
||||
import Lens.Micro ((^.), (&), (.~), (?~))
|
||||
import Lens.Micro ((^.), (&), (.~), (?~), (%~))
|
||||
import Test.Hspec
|
||||
( Spec
|
||||
, context
|
||||
|
@ -46,6 +46,7 @@ spec = describe "Mtlstats.Actions" $ do
|
|||
startNewSeasonSpec
|
||||
startNewGameSpec
|
||||
resetYtdSpec
|
||||
clearRookiesSpec
|
||||
resetStandingsSpec
|
||||
addCharSpec
|
||||
removeCharSpec
|
||||
|
@ -129,6 +130,45 @@ resetYtdSpec = describe "resetYtd" $
|
|||
lt ^. gsTies `shouldNotBe` 0) $
|
||||
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 = describe "resetStandings" $ do
|
||||
let
|
||||
|
|
Loading…
Reference in New Issue
Block a user