Skip to content

Commit

Permalink
Add test, make new events "sync"
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahTheDuke committed Aug 12, 2019
1 parent dc6d1bd commit f93b671
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/clj/game/cards/hardware.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@
(do (system-msg state :runner "trashes Respirocytes as it reached 3 power counters")
(trash state side eid card {:unpreventable true}))
(effect-completed state side eid))))}]
{:effect (req (damage state side eid :meat 1 {:unboostable true :card card}))
{:effect (effect (damage eid :meat 1 {:unboostable true :card card}))
:msg "suffer 1 meat damage"
:events {:runner-hand-change {:req (req (and (zero? target)
(first-event? state side :runner-hand-change #(zero? (first %)))))
Expand Down
13 changes: 7 additions & 6 deletions src/clj/game/core/cards.clj
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,13 @@
(when-let [move-zone-fn (:move-zone (card-def moved-card))]
(move-zone-fn state side (make-eid state) moved-card card))
(trigger-event state side :card-moved card (assoc moved-card :move-to-side side))
(when-let [z (or (#{:discard :hand :deck} src-zone)
(#{:discard :hand :deck} to))]
(let [event (keyword (str (name side) "-" (name z) "-change"))]
; (trigger-event state side :corp-hand-change card moved-card)
; (trigger-event state side :runner-discard-change card moved-card)
(trigger-event state side event (count (get-in @state [side z])) moved-card)))
(when-let [zone (or (#{:discard :hand :deck} src-zone)
(#{:discard :hand :deck} to))]
(let [event (keyword (str (name side) "-" (name zone) "-change"))]
; To easily grep:
; :corp-hand-change :corp-deck-change :corp-discard-change
; :runner-hand-change :runner-deck-change :runner-discard-change
(trigger-event-sync state side (make-eid state) event (count (get-in @state [side zone])) moved-card)))
;; Default a card when moved to inactive zones (except :persistent key)
(when (#{:discard :hand :deck :rfg :scored} to)
(reset-card state side moved-card)
Expand Down
21 changes: 20 additions & 1 deletion test/clj/game_test/cards/hardware.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1780,7 +1780,26 @@
(take-credits state :runner)
(take-credits state :corp)
(is (zero? (-> (get-runner) :hand count))
"Respirocytes still does not trigger when trashed")))))
"Respirocytes still does not trigger when trashed"))))
(testing "Should wait to draw until after draws are handled. #4190"
(do-game
(new-game {:runner {:hand [(qty "Respirocytes" 4) "The Class Act"
"Acacia" "Bankroll" "Cache"]
:credits 10}})
(take-credits state :corp)
(core/move state :runner (find-card "Acacia" (:hand (get-runner))) :deck)
(core/move state :runner (find-card "Bankroll" (:hand (get-runner))) :deck)
(core/move state :runner (find-card "Cache" (:hand (get-runner))) :deck)
(play-from-hand state :runner "The Class Act")
(play-from-hand state :runner "Respirocytes")
(play-from-hand state :runner "Respirocytes")
(is (= 2 (count (:discard (get-runner)))) "2 damage done")
(is (= ["Acacia" "Bankroll"] (->> (get-runner) :prompt first :choices (map :title)))
"First Respirocytes triggers The Class Act")
(is (zero? (count (:hand (get-runner)))) "Runner hasn't drawn anything yet")
(click-prompt state :runner "Acacia")
(is (= ["Bankroll" "Cache"] (->> (get-runner) :hand (map :title)))
"Acacia is on the bottom of the deck so Runner drew Cache"))))

(deftest rubicon-switch
;; Rubicon Switch
Expand Down

0 comments on commit f93b671

Please sign in to comment.