implemented resetCreatePlayerState and resetCreateGoalieState
This commit is contained in:
parent
2d2ee61aae
commit
667cf34475
|
@ -34,6 +34,8 @@ module Mtlstats.Actions
|
|||
, createGoalie
|
||||
, addPlayer
|
||||
, addGoalie
|
||||
, resetCreatePlayerState
|
||||
, resetCreateGoalieState
|
||||
, recordGoalAssists
|
||||
, awardGoal
|
||||
, awardAssist
|
||||
|
@ -172,6 +174,19 @@ addPlayer s = fromMaybe s $ do
|
|||
addGoalie :: ProgState -> ProgState
|
||||
addGoalie = undefined
|
||||
|
||||
-- | Resets the 'CreatePlayerState' value
|
||||
resetCreatePlayerState :: ProgState -> ProgState
|
||||
resetCreatePlayerState = progMode.createPlayerStateL
|
||||
%~ (cpsNumber .~ Nothing)
|
||||
. (cpsName .~ "")
|
||||
. (cpsPosition .~ "")
|
||||
|
||||
-- | Resets the 'CreateGoalieState' value
|
||||
resetCreateGoalieState :: ProgState -> ProgState
|
||||
resetCreateGoalieState = progMode.createGoalieStateL
|
||||
%~ (cgsNumber .~ Nothing)
|
||||
. (cgsName .~ "")
|
||||
|
||||
-- | Awards the goal and assists to the players
|
||||
recordGoalAssists :: ProgState -> ProgState
|
||||
recordGoalAssists ps = fromMaybe ps $ do
|
||||
|
|
|
@ -43,6 +43,8 @@ import Mtlstats.Actions
|
|||
import Mtlstats.Types
|
||||
import Mtlstats.Util
|
||||
|
||||
import qualified TypesSpec as TS
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "Mtlstats.Actions" $ do
|
||||
startNewSeasonSpec
|
||||
|
@ -56,6 +58,8 @@ spec = describe "Mtlstats.Actions" $ do
|
|||
createPlayerSpec
|
||||
createGoalieSpec
|
||||
addPlayerSpec
|
||||
resetCreatePlayerStateSpec
|
||||
resetCreateGoalieStateSpec
|
||||
recordGoalAssistsSpec
|
||||
awardGoalSpec
|
||||
awardAssistSpec
|
||||
|
@ -384,6 +388,25 @@ addPlayerSpec = describe "addPlayer" $ do
|
|||
s' = addPlayer $ s MainMenu
|
||||
in s'^.database.dbPlayers `shouldBe` [p1]
|
||||
|
||||
resetCreatePlayerStateSpec :: Spec
|
||||
resetCreatePlayerStateSpec = describe "resetCreatePlayerState" $ let
|
||||
cps = newCreatePlayerState
|
||||
& cpsNumber ?~ 1
|
||||
& cpsName .~ "Joe"
|
||||
& cpsPosition .~ "centre"
|
||||
ps = resetCreatePlayerState $
|
||||
newProgState & progMode.createPlayerStateL .~ cps
|
||||
in TS.compareTest (ps^.progMode.createPlayerStateL) newCreatePlayerState
|
||||
|
||||
resetCreateGoalieStateSpec :: Spec
|
||||
resetCreateGoalieStateSpec = describe "resetCreateGoalieState" $ let
|
||||
cgs = newCreateGoalieState
|
||||
& cgsNumber ?~ 1
|
||||
& cgsName .~ "Joe"
|
||||
ps = resetCreateGoalieState $
|
||||
newProgState & progMode.createGoalieStateL .~ cgs
|
||||
in TS.compareTest (ps^.progMode.createGoalieStateL) newCreateGoalieState
|
||||
|
||||
recordGoalAssistsSpec :: Spec
|
||||
recordGoalAssistsSpec = describe "recordGoalAssists" $ do
|
||||
let
|
||||
|
|
Loading…
Reference in New Issue
Block a user