record active flag on player creation
This commit is contained in:
parent
960fbb3443
commit
e28ef1ff0e
|
@ -163,11 +163,13 @@ addPlayer s = fromMaybe s $ do
|
||||||
let cps = s^.progMode.createPlayerStateL
|
let cps = s^.progMode.createPlayerStateL
|
||||||
num <- cps^.cpsNumber
|
num <- cps^.cpsNumber
|
||||||
rFlag <- cps^.cpsRookieFlag
|
rFlag <- cps^.cpsRookieFlag
|
||||||
|
aFlag <- cps^.cpsActiveFlag
|
||||||
let
|
let
|
||||||
name = cps^.cpsName
|
name = cps^.cpsName
|
||||||
pos = cps^.cpsPosition
|
pos = cps^.cpsPosition
|
||||||
player = newPlayer num name pos
|
player = newPlayer num name pos
|
||||||
& pRookie .~ rFlag
|
& pRookie .~ rFlag
|
||||||
|
& pActive .~ aFlag
|
||||||
Just $ s & database.dbPlayers
|
Just $ s & database.dbPlayers
|
||||||
%~ (++[player])
|
%~ (++[player])
|
||||||
|
|
||||||
|
|
|
@ -321,30 +321,40 @@ addPlayerSpec = describe "addPlayer" $ mapM_
|
||||||
ps' = addPlayer ps
|
ps' = addPlayer ps
|
||||||
in ps'^.database.dbPlayers `shouldBe` players)
|
in ps'^.database.dbPlayers `shouldBe` players)
|
||||||
|
|
||||||
-- label, expectation, progMode, players
|
-- label, expectation, progMode, players
|
||||||
[ ( "wrong mode", failure, MainMenu, [joe] )
|
[ ( "wrong mode", failure, MainMenu, [joe] )
|
||||||
, ( "missing number", failure, noNum, [joe] )
|
, ( "missing number", failure, noNum, [joe] )
|
||||||
, ( "missing rookie flag", failure, noRookie, [joe] )
|
, ( "missing rookie flag", failure, noRookie, [joe] )
|
||||||
, ( "rookie", success, mkRookie, [joe, rookie] )
|
, ( "missing active flag", failure, noActive, [joe] )
|
||||||
, ( "normal player", success, mkNormal, [joe, normal] )
|
, ( "rookie", success, mkRookie, [joe, rookie] )
|
||||||
|
, ( "retired", success, mkRetired, [joe, retired] )
|
||||||
|
, ( "normal player", success, mkNormal, [joe, normal] )
|
||||||
]
|
]
|
||||||
|
|
||||||
where
|
where
|
||||||
failure = "should not create the player"
|
failure = "should not create the player"
|
||||||
success = "should create the player"
|
success = "should create the player"
|
||||||
noNum = mkpm Nothing (Just False)
|
noNum = mkpm Nothing (Just False) (Just True)
|
||||||
noRookie = mkpm (Just 3) Nothing
|
noRookie = mkpm (Just 3) Nothing (Just True)
|
||||||
mkRookie = mkpm (Just 3) (Just True)
|
noActive = mkpm (Just 3) (Just False) Nothing
|
||||||
mkNormal = mkpm (Just 3) (Just False)
|
mkRookie = mkpm (Just 3) (Just True) (Just True)
|
||||||
|
mkRetired = mkpm (Just 3) (Just False) (Just False)
|
||||||
|
mkNormal = mkpm (Just 3) (Just False) (Just True)
|
||||||
joe = newPlayer 2 "Joe" "centre"
|
joe = newPlayer 2 "Joe" "centre"
|
||||||
rookie = bob True
|
rookie = bob True True
|
||||||
normal = bob False
|
retired = bob False False
|
||||||
bob rf = newPlayer 3 "Bob" "defense" & pRookie .~ rf
|
normal = bob False True
|
||||||
mkpm n rf = CreatePlayer $ newCreatePlayerState
|
|
||||||
|
bob r a = newPlayer 3 "Bob" "defense"
|
||||||
|
& pRookie .~ r
|
||||||
|
& pActive .~ a
|
||||||
|
|
||||||
|
mkpm n r a = CreatePlayer $ newCreatePlayerState
|
||||||
& cpsNumber .~ n
|
& cpsNumber .~ n
|
||||||
& cpsName .~ "Bob"
|
& cpsName .~ "Bob"
|
||||||
& cpsPosition .~ "defense"
|
& cpsPosition .~ "defense"
|
||||||
& cpsRookieFlag .~ rf
|
& cpsRookieFlag .~ r
|
||||||
|
& cpsActiveFlag .~ a
|
||||||
|
|
||||||
addGoalieSpec :: Spec
|
addGoalieSpec :: Spec
|
||||||
addGoalieSpec = describe "addGoalie" $ mapM_
|
addGoalieSpec = describe "addGoalie" $ mapM_
|
||||||
|
|
Loading…
Reference in New Issue
Block a user