Skip to content

Commit

Permalink
Merge pull request #7241 from butzopower/bmi-buffer
Browse files Browse the repository at this point in the history
Implement BMI Buffer and BMI Buffer 2
  • Loading branch information
NoahTheDuke authored Dec 5, 2023
2 parents cb62f20 + 585562c commit 3e551ab
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 1 deletion.
48 changes: 47 additions & 1 deletion src/clj/game/cards/hardware.clj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
[game.core.events :refer [event-count first-event? first-trash? no-event?
run-events]]
[game.core.expose :refer [expose]]
[game.core.finding :refer [find-card]]
[game.core.finding :refer [find-card find-latest]]
[game.core.flags :refer [can-trash? card-flag? in-corp-scored? register-run-flag!
zone-locked?]]
[game.core.gaining :refer [gain-clicks gain-credits lose-clicks
Expand Down Expand Up @@ -234,6 +234,52 @@
card nil)
(rez state :corp eid target))))}]})

(defcard "BMI Buffer"
(let [grip-program-trash?
(fn [card]
(and (runner? card)
(program? card)
(in-discard? card)
(= (first (:previous-zone card)) :hand)))
triggered-ability
{:async true
:effect (req (doseq [c (filter grip-program-trash? (mapv #(find-latest state (:card %)) targets))]
(host state side (get-card state card) c))
(effect-completed state side eid))}]
{:events [(assoc triggered-ability :event :runner-trash)
(assoc triggered-ability :event :corp-trash)]
:abilities [{:cost [:click 2]
:label "Install a hosted program"
:prompt "Choose a program to install"
:choices (req (cancellable (filter #(can-pay? state side (assoc eid :source card :source-type :runner-install)
% nil [:credit (install-cost state side %)])
(:hosted card))))
:msg (msg "install " (:title target))
:async true
:effect (effect (runner-install (assoc eid :source card :source-type :runner-install) target))}]}))

(defcard "BMI Buffer 2"
(let [grip-program-trash?
(fn [card]
(and (runner? card)
(program? card)
(in-discard? card)
(= (first (:previous-zone card)) :hand)))
triggered-ability
{:async true
:effect (req (doseq [c (filter grip-program-trash? (mapv #(find-latest state (:card %)) targets))]
(host state side (get-card state card) c))
(effect-completed state side eid))}]
{:events [(assoc triggered-ability :event :runner-trash)
(assoc triggered-ability :event :corp-trash)]
:abilities [{:cost [:click 2]
:label "Install a hosted program"
:prompt "Choose a program to install"
:choices (req (:hosted card))
:msg (msg "install " (:title target))
:async true
:effect (effect (runner-install (assoc eid :source card :source-type :runner-install) target {:ignore-all-cost true}))}]}))

(defcard "Bookmark"
{:abilities [{:label "Host up to 3 cards from the grip facedown"
:cost [:click 1]
Expand Down
39 changes: 39 additions & 0 deletions test/clj/game/cards/hardware_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,45 @@
(click-card state :runner "Ice Wall")
(click-prompt state :corp "No"))))

(deftest bmi-buffer
(do-game
(new-game {:runner {:hand ["Abaasy" "BMI Buffer" "Freelance Coding Contract"]}})
(take-credits state :corp)
(play-from-hand state :runner "BMI Buffer")
(play-from-hand state :runner "Freelance Coding Contract")
(click-card state :runner (find-card "Abaasy" (:hand (get-runner))))
(click-prompt state :runner "Done")
(is (= 0 (count (filter #(= (:type %) "Program") (:discard (get-runner))))) "No programs in Heap")
(is (nil? (get-program state 0)) "Abaasy not installed")
(let [bmi (get-hardware state 0)]
(is (= 1 (count (:hosted bmi))) "BMI Buffer hosting Abaasy")
(changes-val-macro -2 (:credit (get-runner))
"BMI Buffer requires install cost paid"
(card-ability state :runner bmi 0)
(click-prompt state :runner "Abaasy"))
(is (= 0 (count (:hosted (refresh bmi)))) "BMI Buffer no longer hosting Abaasy")
(is (= "Abaasy" (:title (get-program state 0))) "Abaasy is installed"))))

(deftest bmi-buffer-2
;; BMI Buffer 2 installs ignoring all costs
(do-game
(new-game {:runner {:hand ["Abaasy" "BMI Buffer 2" "Freelance Coding Contract"]}})
(take-credits state :corp)
(play-from-hand state :runner "BMI Buffer 2")
(play-from-hand state :runner "Freelance Coding Contract")
(click-card state :runner (find-card "Abaasy" (:hand (get-runner))))
(click-prompt state :runner "Done")
(is (= 0 (count (filter #(= (:type %) "Program") (:discard (get-runner))))) "No programs in Heap")
(is (nil? (get-program state 0)) "Abaasy not installed")
(let [bmi (get-hardware state 0)]
(is (= 1 (count (:hosted bmi))) "BMI Buffer 2 hosting Abaasy")
(changes-val-macro 0 (:credit (get-runner))
"BMI Buffer 2 ignores install cost"
(card-ability state :runner bmi 0)
(click-prompt state :runner "Abaasy"))
(is (= 0 (count (:hosted (refresh bmi)))) "BMI Buffer 2 no longer hosting Abaasy")
(is (= "Abaasy" (:title (get-program state 0))) "Abaasy is installed"))))

(deftest bookmark-click-ability
;; Click ability
(do-game
Expand Down

0 comments on commit 3e551ab

Please sign in to comment.