update awardAssist
This commit is contained in:
@@ -193,8 +193,11 @@ awardAssist
|
|||||||
-> ProgState
|
-> ProgState
|
||||||
-> ProgState
|
-> ProgState
|
||||||
awardAssist n ps = ps
|
awardAssist n ps = ps
|
||||||
& database.dbPlayers
|
& progMode.gameStateL.gamePlayerStats %~
|
||||||
%~ map
|
(\m -> let
|
||||||
|
stats = M.findWithDefault newPlayerStats n m
|
||||||
|
in M.insert n (stats & psAssists %~ succ) m)
|
||||||
|
& database.dbPlayers %~ map
|
||||||
(\(i, p) -> if i == n
|
(\(i, p) -> if i == n
|
||||||
then p
|
then p
|
||||||
& pYtd.psAssists %~ succ
|
& pYtd.psAssists %~ succ
|
||||||
|
|||||||
@@ -477,45 +477,34 @@ awardAssistSpec = describe "awardAssist" $ do
|
|||||||
= newPlayer 2 "Bob" "defense"
|
= newPlayer 2 "Bob" "defense"
|
||||||
& pYtd.psAssists .~ 3
|
& pYtd.psAssists .~ 3
|
||||||
& pLifetime.psAssists .~ 4
|
& pLifetime.psAssists .~ 4
|
||||||
|
joeStats
|
||||||
|
= newPlayerStats
|
||||||
|
& psAssists .~ 1
|
||||||
ps
|
ps
|
||||||
= newProgState
|
= newProgState
|
||||||
|
& progMode.gameStateL.gamePlayerStats .~ M.singleton 0 joeStats
|
||||||
& database.dbPlayers .~ [joe, bob]
|
& database.dbPlayers .~ [joe, bob]
|
||||||
|
|
||||||
context "Joe" $ do
|
mapM_
|
||||||
|
(\(pName, pid, ytd, lt, game) ->
|
||||||
|
context pName $ do
|
||||||
let
|
let
|
||||||
ps' = awardAssist 0 ps
|
ps' = awardAssist pid ps
|
||||||
joe' = head $ ps'^.database.dbPlayers
|
player = (ps'^.database.dbPlayers) !! pid
|
||||||
bob' = last $ ps'^.database.dbPlayers
|
gStats = (ps'^.progMode.gameStateL.gamePlayerStats) M.! pid
|
||||||
|
|
||||||
it "should increment Joe's year-to-date assists" $
|
it ("should increment " ++ pName ++ "'s year-to-date assists") $
|
||||||
joe'^.pYtd.psAssists `shouldBe` 2
|
player^.pYtd.psAssists `shouldBe` ytd
|
||||||
|
|
||||||
it "should increment Joe's lifetime assists" $
|
it ("should increment " ++ pName ++ "'s lifetime assists") $
|
||||||
joe'^.pLifetime.psAssists `shouldBe` 3
|
player^.pLifetime.psAssists `shouldBe` lt
|
||||||
|
|
||||||
it "should leave Bob's year-to-date assists alone" $
|
it ("should increment " ++ pName ++ "'s game assists") $
|
||||||
bob'^.pYtd.psAssists `shouldBe` 3
|
gStats^.psAssists `shouldBe` game)
|
||||||
|
-- player name, player id, ytd assists, lifetime assists, game assists
|
||||||
it "should leave Bob's lifetime assists alone" $
|
[ ( "Joe", 0, 2, 3, 2 )
|
||||||
bob^.pLifetime.psAssists `shouldBe` 4
|
, ( "Bob", 1, 4, 5, 1 )
|
||||||
|
]
|
||||||
context "Bob" $ do
|
|
||||||
let
|
|
||||||
ps' = awardAssist 1 ps
|
|
||||||
joe' = head $ ps'^.database.dbPlayers
|
|
||||||
bob' = last $ ps'^.database.dbPlayers
|
|
||||||
|
|
||||||
it "should leave Joe's year-to-date assists alone" $
|
|
||||||
joe'^.pYtd.psAssists `shouldBe` 1
|
|
||||||
|
|
||||||
it "should leave Joe's lifetime assists alone" $
|
|
||||||
joe'^.pLifetime.psAssists `shouldBe` 2
|
|
||||||
|
|
||||||
it "should increment Bob's year-to-date assists" $
|
|
||||||
bob'^.pYtd.psAssists `shouldBe` 4
|
|
||||||
|
|
||||||
it "should increment Bob's lifetime assists" $
|
|
||||||
bob'^.pLifetime.psAssists `shouldBe` 5
|
|
||||||
|
|
||||||
context "invalid index" $ let
|
context "invalid index" $ let
|
||||||
ps' = awardAssist (-1) ps
|
ps' = awardAssist (-1) ps
|
||||||
|
|||||||
Reference in New Issue
Block a user