Skip to content

Commit

Permalink
Merge pull request #7935 from NBKelly/external-subroutine-trigger-fix
Browse files Browse the repository at this point in the history
External subroutine trigger fix
  • Loading branch information
NoahTheDuke authored Jan 31, 2025
2 parents ee70f98 + b004815 commit 83f35be
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/clj/game/cards/upgrades.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@
{:prompt "Choose a subroutine"
:choices (req (unbroken-subroutines-choice ice))
:msg (msg "resolve the subroutine (\"[subroutine] "
target "\") from " (:title ice))
target "\") from " (:title ice))
:async true
:effect (req (let [sub (first (filter #(= target (make-label (:sub-effect %))) (:subroutines ice)))]
(resolve-subroutine! state side eid ice (assoc sub :external-trigger true))))})
Expand Down
2 changes: 1 addition & 1 deletion src/clj/game/core/ice.clj
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
([state side eid ice sub]
(wait-for (trigger-event-simult state side (make-eid state eid) :pre-resolve-subroutine nil sub ice)
;; this is for cards like marcus batty
(when-not (:exernal-trigger sub)
(when-not (:external-trigger sub)
(update! state :corp (resolve-subroutine ice sub)))
;; TODO - need a way to interact with multiple replacement effects.
(let [replacement (:replace-subroutine (get-current-encounter state))
Expand Down
69 changes: 50 additions & 19 deletions test/clj/game/cards/upgrades_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2467,25 +2467,56 @@
(deftest marcus-batty
;; Marcus Batty
(do-game
(new-game {:corp {:deck [(qty "Hedge Fund" 5)]
:hand ["Marcus Batty" "Ice Wall"]
:credits 10}})
(play-from-hand state :corp "Ice Wall" "HQ")
(play-from-hand state :corp "Marcus Batty" "HQ")
(let [iw (get-ice state :hq 0)
mb (get-content state :hq 0)]
(rez state :corp mb)
(take-credits state :corp)
(run-on state "HQ")
(rez state :corp iw)
(card-ability state :corp mb 0)
(is (= :psi (prompt-type :corp)))
(click-prompt state :corp "1 [Credits]")
(click-prompt state :runner "0 [Credits]")
(click-card state :corp iw)
(click-prompt state :corp "End the run")
(is (not (:run @state)) "Run has ended")
(is (nil? (refresh mb)) "Marcus Batty is trashed"))))
(new-game {:corp {:deck [(qty "Hedge Fund" 5)]
:hand ["Marcus Batty" "Ice Wall"]
:credits 10}})
(play-from-hand state :corp "Ice Wall" "HQ")
(play-from-hand state :corp "Marcus Batty" "HQ")
(let [iw (get-ice state :hq 0)
mb (get-content state :hq 0)]
(rez state :corp mb)
(take-credits state :corp)
(run-on state "HQ")
(rez state :corp iw)
(card-ability state :corp mb 0)
(is (= :psi (prompt-type :corp)))
(click-prompt state :corp "1 [Credits]")
(click-prompt state :runner "0 [Credits]")
(click-card state :corp iw)
(click-prompt state :corp "End the run")
(is (not (:run @state)) "Run has ended")
(is (nil? (refresh mb)) "Marcus Batty is trashed"))))

(deftest marcus-batty-doesnt-mark-subs-as-fired
;; Marcus Batty
(do-game
(new-game {:corp {:deck [(qty "Hedge Fund" 5)]
:hand ["Marcus Batty" "Funhouse"]
:credits 10}})
(play-from-hand state :corp "Funhouse" "HQ")
(play-from-hand state :corp "Marcus Batty" "HQ")
(let [iw (get-ice state :hq 0)
mb (get-content state :hq 0)]
(rez state :corp mb)
(take-credits state :corp)
(run-on state "HQ")
(rez state :corp iw)
(run-continue state :encounter-ice)
(click-prompt state :runner "Take 1 tag")
(is (= 1 (count-tags state)))
(card-ability state :corp mb 0)
(is (= :psi (prompt-type :corp)))
(click-prompt state :corp "1 [Credits]")
(click-prompt state :runner "0 [Credits]")
(click-card state :corp iw)
(click-prompt state :corp "Give the Runner 1 tag unless they pay 4 [Credits]")
(click-prompt state :runner "Take 1 tag")
(is (= 2 (count-tags state)))
(is (not (-> iw refresh :subroutines first :fired)) "sub not considered fired (External trigger)")
(is (nil? (refresh mb)) "Marcus Batty is trashed")
(fire-subs state (refresh iw))
(click-prompt state :runner "Take 1 tag")
(is (-> iw refresh :subroutines first :fired) "sub is now considered fired (regular trigger)"))))

(deftest mason-bellamy
(do-game
Expand Down

0 comments on commit 83f35be

Please sign in to comment.