Skip to content

Commit

Permalink
Merge pull request #5159 from lostgeek/jeeves-tests
Browse files Browse the repository at this point in the history
Reworked Jeeves and added a few tests
  • Loading branch information
NoahTheDuke authored Jun 27, 2020
2 parents 3a433e0 + 8b8878c commit a17c7e5
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 66 deletions.
21 changes: 13 additions & 8 deletions src/clj/game/cards/assets.clj
Original file line number Diff line number Diff line change
Expand Up @@ -940,14 +940,19 @@
{:abilities [ability]
:leave-play cleanup
:events [{:event :corp-spent-click
:effect (req (let [target (or (first (filter number? target))
(first target))]
(when-not target
(print-stack-trace (Exception. (str "WHY JEEVES WHY: " targets))))
(update! state side (update-in card [:seen-this-turn (or target :this-is-a-hack)]
(fnil + 0) (second targets)))
(when (>= (get-in (get-card state card) [:seen-this-turn (or target :this-is-a-hack)]) 3)
(resolve-ability state side ability card nil))))}
:effect (req (let [cid (first target)
ability-idx (:ability-idx (:source-info eid))
bac-cid (get-in @state [:corp :basic-action-card :cid])
cause (if (keyword? (first target))
(case (first target)
:play-instant [bac-cid 3]
:corp-click-install [bac-cid 2]
(first target)) ; in clojure there's: (= [1 2 3] '(1 2 3))
[cid ability-idx])
clicks-spent (+ (get-in card [:seen-this-turn cause] 0) (second targets))]
(update! state side (assoc-in card [:seen-this-turn cause] clicks-spent))
(when (>= clicks-spent 3) ; can be >= 3 because :once :per-turn on ability
(resolve-ability state side ability (get-card state card) nil))))}
{:event :corp-turn-ends
:effect cleanup}]}))

Expand Down
10 changes: 5 additions & 5 deletions src/clj/game/cards/identities.clj
Original file line number Diff line number Diff line change
Expand Up @@ -994,10 +994,10 @@
bac-cid (get-in @state [:corp :basic-action-card :cid])
cause (if (keyword? (first target))
(case (first target)
:play-instant (seq [bac-cid 3])
:corp-click-install (seq [bac-cid 2])
(first target))
(seq [cid ability-idx]))
:play-instant [bac-cid 3]
:corp-click-install [bac-cid 2]
(first target)) ; in clojure there's: (= [1 2 3] '(1 2 3))
[cid ability-idx])
prev-actions (get-in card [:special :mm-actions] [])
actions (conj prev-actions cause)]
(update! state side (assoc-in card [:special :mm-actions] actions))
Expand All @@ -1011,7 +1011,7 @@
:req (req (and (get-in card [:special :mm-click])
(let [cid (:cid target)
ability-idx (nth targets 2 nil)
cause (seq [cid ability-idx])
cause [cid ability-idx]
prev-actions (get-in card [:special :mm-actions] [])
actions (conj prev-actions cause)]
(not (and (= 4 (count actions))
Expand Down
156 changes: 103 additions & 53 deletions test/clj/game/cards/assets_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2197,59 +2197,109 @@

(deftest jeeves-model-bioroids
;; Jeeves Model Bioroids
(do-game
(new-game {:corp {:deck ["Jeeves Model Bioroids" "TGTBT"
(qty "Melange Mining Corp." 2)]}
:runner {:deck [(qty "Ghost Runner" 3)]}})
(play-from-hand state :corp "Jeeves Model Bioroids" "New remote")
(core/rez state :corp (get-content state :remote1 0))
(take-credits state :corp)
(play-from-hand state :runner "Ghost Runner")
(play-from-hand state :runner "Ghost Runner")
(play-from-hand state :runner "Ghost Runner")
(take-credits state :runner)
; install 3 things
(play-from-hand state :corp "TGTBT" "New remote")
(play-from-hand state :corp "Melange Mining Corp." "New remote")
(play-from-hand state :corp "Melange Mining Corp." "New remote")
(is (= 1 (:click (get-corp))))
(take-credits state :corp)
(take-credits state :runner)
;;click for credits
(take-credits state :corp 3)
(is (= 1 (:click (get-corp))))
(take-credits state :corp)
(take-credits state :runner)
;;click to purge
(core/do-purge state :corp 3)
(is (= 1 (:click (get-corp))))
(take-credits state :corp)
(take-credits state :runner)
;;click to advance
(core/advance state :corp (get-content state :remote2 0))
(core/advance state :corp (get-content state :remote2 0))
(core/advance state :corp (get-content state :remote2 0))
(is (= 1 (:click (get-corp))))
(take-credits state :corp)
(take-credits state :runner)
;; use 3 clicks on card ability - Melange
(core/rez state :corp (get-content state :remote3 0))
(card-ability state :corp (get-content state :remote3 0) 0)
(is (= 1 (:click (get-corp))))
(take-credits state :corp)
(take-credits state :runner)
;; trash 3 resources
(gain-tags state :runner 1)
(core/trash-resource state :corp nil)
(click-card state :corp (get-resource state 0))
(is (= 1 (count (:discard (get-runner)))))
(core/trash-resource state :corp nil)
(click-card state :corp (get-resource state 0))
(is (= 2 (count (:discard (get-runner)))))
(core/trash-resource state :corp nil)
(click-card state :corp (get-resource state 0))
(is (= 3 (count (:discard (get-runner)))))
(is (= 1 (:click (get-corp))))))
(testing "Cases where Jeeves should trigger"
(testing "Install three different cards"
(do-game
(new-game {:corp {:deck ["Jeeves Model Bioroids" "TGTBT" (qty "Melange Mining Corp." 2)]}})
(play-from-hand state :corp "Jeeves Model Bioroids" "New remote")
(core/rez state :corp (get-content state :remote1 0))
(take-credits state :corp)
(take-credits state :runner)
(play-from-hand state :corp "TGTBT" "New remote")
(play-from-hand state :corp "Melange Mining Corp." "New remote")
(play-from-hand state :corp "Melange Mining Corp." "New remote")
(is (= 1 (:click (get-corp))) "Jeeves triggered")))
(testing "Click for credits three times"
(do-game
(new-game {:corp {:deck ["Jeeves Model Bioroids"]}})
(play-from-hand state :corp "Jeeves Model Bioroids" "New remote")
(core/rez state :corp (get-content state :remote1 0))
(take-credits state :corp)
(take-credits state :runner)
(take-credits state :corp 3)
(is (= 1 (:click (get-corp))) "Jeeves triggered")))
(testing "Spending three clicks to purge"
(do-game
(new-game {:corp {:deck ["Jeeves Model Bioroids"]}})
(play-from-hand state :corp "Jeeves Model Bioroids" "New remote")
(core/rez state :corp (get-content state :remote1 0))
(take-credits state :corp)
(take-credits state :runner)
(core/do-purge state :corp nil)
(is (= 1 (:click (get-corp))) "Jeeves triggered")))
(testing "Spending three clicks to purge"
(do-game
(new-game {:corp {:deck ["Jeeves Model Bioroids" "Project Beale"]}})
(play-from-hand state :corp "Jeeves Model Bioroids" "New remote")
(play-from-hand state :corp "Project Beale" "New remote")
(core/rez state :corp (get-content state :remote1 0))
(take-credits state :corp)
(take-credits state :runner)
(dotimes [_ 3] (core/click-advance state :corp {:card (get-content state :remote2 0)}))
(is (= 1 (:click (get-corp))) "Jeeves triggered")))
(testing "Use 3 clicks on a single card ability - Melange"
(do-game
(new-game {:corp {:deck ["Jeeves Model Bioroids" "Melange Mining Corp."]}})
(play-from-hand state :corp "Jeeves Model Bioroids" "New remote")
(play-from-hand state :corp "Melange Mining Corp." "New remote")
(core/rez state :corp (get-content state :remote1 0))
(take-credits state :corp)
(take-credits state :runner)
;; use 3 clicks on card ability - Melange
(core/rez state :corp (get-content state :remote2 0))
(card-ability state :corp (get-content state :remote2 0) 0)
(is (= 1 (:click (get-corp))) "Jeeves triggered")))
(testing "Trashing three different resources"
(do-game
(new-game {:corp {:deck ["Jeeves Model Bioroids"]
:credits 10}
:runner {:deck [(qty "Ghost Runner" 3)]}})
(play-from-hand state :corp "Jeeves Model Bioroids" "New remote")
(core/rez state :corp (get-content state :remote1 0))
(take-credits state :corp)
(dotimes [_ 3] (play-from-hand state :runner "Ghost Runner"))
(take-credits state :runner)
(gain-tags state :runner 1)
(dotimes [n 3]
(core/trash-resource state :corp nil)
(click-card state :corp (get-resource state 0))
(is (= (inc n) (count (:discard (get-runner)))) "Correct number of cards in Runner discard"))
(is (= 1 (:click (get-corp))) "Jeeves triggered"))))
(testing "Cases where Jeeves should not trigger"
(testing "Three different basic actions"
(do-game
(new-game {:corp {:hand ["Jeeves Model Bioroids" "Project Vitruvius"]}})
(play-from-hand state :corp "Jeeves Model Bioroids" "New remote")
(play-from-hand state :corp "Project Vitruvius" "New remote")
(core/rez state :corp (get-content state :remote1 0))
(take-credits state :corp)
(take-credits state :runner)
(core/click-advance state :corp {:card (get-content state :remote2 0)})
(core/click-credit state :corp nil)
(core/click-advance state :corp {:card (get-content state :remote2 0)})
(is (= 0 (:click (get-corp))) "Jeeves did not trigger")))
(testing "Three different asset abilities"
(do-game
(new-game {:corp {:hand ["Jeeves Model Bioroids" (qty "Nanoetching Matrix" 3)]}})
(core/gain state :corp :click 1)
(play-from-hand state :corp "Jeeves Model Bioroids" "New remote")
(play-from-hand state :corp "Nanoetching Matrix" "New remote")
(play-from-hand state :corp "Nanoetching Matrix" "New remote")
(play-from-hand state :corp "Nanoetching Matrix" "New remote")
(let [jev (get-content state :remote1 0)
nm1 (get-content state :remote2 0)
nm2 (get-content state :remote3 0)
nm3 (get-content state :remote4 0)]
(core/rez state :corp jev)
(core/rez state :corp nm1)
(core/rez state :corp nm2)
(core/rez state :corp nm3)
(take-credits state :corp)
(take-credits state :runner)
(card-ability state :corp nm1 0)
(card-ability state :corp nm2 0)
(card-ability state :corp nm3 0)
(is (= 0 (:click (get-corp))) "Jeeves did not trigger"))))))

(deftest kala-ghoda-real-tv
;; Kala Ghoda Real TV
Expand Down

0 comments on commit a17c7e5

Please sign in to comment.