Skip to content

Commit

Permalink
Merge pull request #16 from mharris717/tlm-tests
Browse files Browse the repository at this point in the history
Thanks!! 👍
  • Loading branch information
JoelCFC25 committed May 26, 2016
2 parents 76197b1 + b7e14b3 commit e81c9f6
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 26 deletions.
5 changes: 5 additions & 0 deletions src/clj/game/cards-operations.clj
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@
cpts-corp (get-agenda-points state :corp c)
rpts-runner (get-agenda-points state :runner r)
cpts-runner (get-agenda-points state :runner c)]

; Remove end of turn events for swapped out agenda
(swap! state update-in [:corp :register :end-turn]
(fn [events] (filter #(not (= (:cid c) (get-in % [:card :cid]))) events)))

(swap! state update-in [:corp :scored]
(fn [coll] (conj (remove-once #(not= (:cid %) (:cid c)) coll) r)))
(swap! state update-in [:runner :scored]
Expand Down
27 changes: 27 additions & 0 deletions src/clj/test/cards/events.clj
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,33 @@
(is (= 1 (count (get-in @state [:runner :rig :program]))) "Installed Nerve Agent")
(is (= 4 (:credit (get-runner))) "Paid 0 credits")))

(deftest noble-path
"The Noble Path - Prevents damage during run"
(do-game
(new-game (default-corp) (default-runner [(qty "The Noble Path" 1) (qty "Hedge Fund" 2)]))
(let [hand-count #(count (:hand (get-runner)))]
(starting-hand state :runner ["The Noble Path" "Hedge Fund"])
(take-credits state :corp)

; Play The Noble Path and confirm it trashes remaining cards in hand
(is (= 2 (hand-count)) "Start with 2 cards")
(play-from-hand state :runner "The Noble Path")
(is (= 0 (hand-count)) "Playing Noble Path trashes the remaining cards in hand")

; Put a card into hand so I can confirm it's not discarded by damage
; Don't want to dealing with checking damage on a zero card hand
(starting-hand state :runner ["Hedge Fund"])

(core/damage state :runner :net 1)
(is (= 1 (hand-count)) "Damage was prevented")

; Finish the run and check that damage works again
(prompt-choice :runner "HQ")
(run-successful state)
(prompt-choice :runner "OK")
(core/damage state :runner :net 1)
(is (= 0 (hand-count)) "Damage works again after run"))))

(deftest notoriety
"Notoriety - Run all 3 central servers successfully and play to gain 1 agenda point"
(do-game
Expand Down
61 changes: 61 additions & 0 deletions src/clj/test/cards/operations.clj
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,67 @@
(play-from-hand state :corp "Diversified Portfolio")
(is (= 7 (:credit (get-corp))) "Ignored remote with ICE but no server contents")))

(deftest exchange-of-information
"Exchange of Information - Swapping agendas works correctly"
(do-game
(new-game (default-corp [(qty "Exchange of Information" 1)
(qty "Market Research" 1)
(qty "Breaking News" 1)
(qty "Project Beale" 1)
(qty "Explode-a-palooza" 1)])
(default-runner))

(score-agenda state :corp (find-card "Market Research" (:hand (get-corp))))
(score-agenda state :corp (find-card "Breaking News" (:hand (get-corp))))
(is (= 2 (:tag (get-runner))) "Runner gained 2 tags")
(take-credits state :corp)
(is (= 0 (:tag (get-runner))) "Runner lost 2 tags")

(core/steal state :runner (find-card "Project Beale" (:hand (get-corp))))
(core/steal state :runner (find-card "Explode-a-palooza" (:hand (get-corp))))
(take-credits state :runner)

(is (= 4 (:agenda-point (get-runner))))
(is (= 3 (:agenda-point (get-corp))))

(core/gain state :runner :tag 1)
(play-from-hand state :corp "Exchange of Information")

(prompt-select :corp (find-card "Project Beale" (:scored (get-runner))))
(prompt-select :corp (find-card "Breaking News" (:scored (get-corp))))

(is (= 3 (:agenda-point (get-runner))))
(is (= 4 (:agenda-point (get-corp))))))

(deftest exchange-of-information-breaking-news
"Exchange of Information - Swapping a just scored Breaking News keeps the tags"
(do-game
(new-game (default-corp [(qty "Exchange of Information" 1)
(qty "Market Research" 1)
(qty "Breaking News" 1)
(qty "Project Beale" 1)
(qty "Explode-a-palooza" 1)])
(default-runner))

(take-credits state :corp)

(core/steal state :runner (find-card "Project Beale" (:hand (get-corp))))
(core/steal state :runner (find-card "Explode-a-palooza" (:hand (get-corp))))
(take-credits state :runner)

(score-agenda state :corp (find-card "Breaking News" (:hand (get-corp))))
(is (= 2 (:tag (get-runner))) "Runner gained 2 tags")
(play-from-hand state :corp "Exchange of Information")

(prompt-select :corp (find-card "Project Beale" (:scored (get-runner))))
(prompt-select :corp (find-card "Breaking News" (:scored (get-corp))))
(is (= 2 (:tag (get-runner))) "Still has tags after swap and before end of turn")

(take-credits state :corp)
(is (= 3 (:agenda-point (get-runner))))
(is (= 2 (:agenda-point (get-corp))))
(is (= 2 (:tag (get-runner))) "Runner does not lose tags at end of turn")))

(deftest election-day
(do-game
(new-game (default-corp [(qty "Election Day" 7)])
Expand Down
33 changes: 7 additions & 26 deletions src/clj/test/cards/resources.clj
Original file line number Diff line number Diff line change
Expand Up @@ -842,10 +842,7 @@
(qty "Torch" 1)
(qty "Sure Gamble" 2)]))
(take-credits state :corp)
;; move Gordian back to deck
(core/move state :runner (find-card "Gordian Blade" (:hand (get-runner))) :deck)
(core/move state :runner (find-card "Sure Gamble" (:hand (get-runner))) :deck)
(core/move state :runner (find-card "Torch" (:hand (get-runner))) :deck)
(starting-hand state :runner ["Street Peddler" "Sure Gamble"])
(play-from-hand state :runner "Street Peddler")
(let [sp (get-in @state [:runner :rig :resource 0])]
(is (= 3 (count (:hosted sp))) "Street Peddler is hosting 3 cards")
Expand All @@ -861,10 +858,7 @@
(new-game (default-corp)
(default-runner [(qty "Street Peddler" 1) (qty "Gordian Blade" 3)]))
(take-credits state :corp)
;; move Gordian back to deck
(core/move state :runner (find-card "Gordian Blade" (:hand (get-runner))) :deck)
(core/move state :runner (find-card "Gordian Blade" (:hand (get-runner))) :deck)
(core/move state :runner (find-card "Gordian Blade" (:hand (get-runner))) :deck)
(starting-hand state :runner ["Street Peddler"])
(play-from-hand state :runner "Street Peddler")
(let [sp (get-in @state [:runner :rig :resource 0])]
(card-ability state :runner sp 0)
Expand All @@ -885,10 +879,7 @@
(qty "Gordian Blade" 1)
(qty "Sure Gamble" 2)]))
(take-credits state :corp)
;; move Gordian back to deck
(core/move state :runner (find-card "Gordian Blade" (:hand (get-runner))) :deck)
(core/move state :runner (find-card "Sure Gamble" (:hand (get-runner))) :deck)
(core/move state :runner (find-card "Sure Gamble" (:hand (get-runner))) :deck)
(starting-hand state :runner ["Street Peddler"])
(play-from-hand state :runner "Street Peddler")
(let [sp (get-in @state [:runner :rig :resource 0])]
;; should still be able to afford Gordian w/ Kate discount
Expand All @@ -907,10 +898,7 @@
(new-game (default-corp)
(default-runner [(qty "Street Peddler" 1) (qty "Corroder" 3)]))
(take-credits state :corp)
;; move Corroders back to deck
(core/move state :runner (find-card "Corroder" (:hand (get-runner))) :deck)
(core/move state :runner (find-card "Corroder" (:hand (get-runner))) :deck)
(core/move state :runner (find-card "Corroder" (:hand (get-runner))) :deck)
(starting-hand state :runner ["Street Peddler"])
(play-from-hand state :runner "Street Peddler")
(is (= 4 (:memory (get-runner))) "No memory cost for hosting on Street Peddler")
(let [sp (get-in @state [:runner :rig :resource 0])]
Expand All @@ -927,10 +915,7 @@
(new-game (default-corp)
(default-runner [(qty "Street Peddler" 1) (qty "HQ Interface" 3)]))
(take-credits state :corp)
;; move HQIs back to deck
(core/move state :runner (find-card "HQ Interface" (:hand (get-runner))) :deck)
(core/move state :runner (find-card "HQ Interface" (:hand (get-runner))) :deck)
(core/move state :runner (find-card "HQ Interface" (:hand (get-runner))) :deck)
(starting-hand state :runner ["Street Peddler"])
(play-from-hand state :runner "Street Peddler")
(let [sp (get-in @state [:runner :rig :resource 0])]
(card-ability state :runner sp 0)
Expand All @@ -945,10 +930,7 @@
(default-runner [(qty "Street Peddler" 1) (qty "Parasite" 3)]))
(play-from-hand state :corp "Pop-up Window" "HQ")
(take-credits state :corp 2)
;; move Parasites back to deck
(core/move state :runner (find-card "Parasite" (:hand (get-runner))) :deck)
(core/move state :runner (find-card "Parasite" (:hand (get-runner))) :deck)
(core/move state :runner (find-card "Parasite" (:hand (get-runner))) :deck)
(starting-hand state :runner ["Street Peddler"])
(core/lose state :runner :credit 4) ; go down to 1 credit
(is (= 1 (:credit (get-runner))) "Runner has 1 credit")
(play-from-hand state :runner "Street Peddler")
Expand All @@ -970,8 +952,7 @@
(default-runner [(qty "Street Peddler" 1)
(qty "Tech Trader" 1)]))
(take-credits state :corp)
;; move Gordian back to deck
(core/move state :runner (find-card "Tech Trader" (:hand (get-runner))) :deck)
(starting-hand state :runner ["Street Peddler"])
(play-from-hand state :runner "Street Peddler")
(let [sp (get-in @state [:runner :rig :resource 0])]
(is (= 1 (count (:hosted sp))) "Street Peddler is hosting 1 card")
Expand Down

0 comments on commit e81c9f6

Please sign in to comment.