Skip to content

Commit 4f6d565

Browse files
committed
shift key automation works for bad pub credits
1 parent e376881 commit 4f6d565

File tree

10 files changed

+60
-32
lines changed

10 files changed

+60
-32
lines changed

src/clj/game/core/actions.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,14 @@
241241
(effect-completed state side eid)))
242242
243243
(defn resolve-bad-pub-choice
244-
[state side {:keys [eid] :as args}]
244+
[state side {:keys [eid shift-key-held] :as args}]
245245
(if (pos? (bad-publicity-available state side))
246246
(let [prompt (or (first-prompt-by-eid state side eid)
247247
(first (get-in @state [side :prompt])))
248248
card (:card prompt)
249249
prompt-eid eid
250250
effect (:effect prompt)]
251+
(swap! state assoc-in [side :shift-key-select] shift-key-held)
251252
(if (:offer-bad-pub? prompt)
252253
(do (remove-from-prompt-queue state side prompt)
253254
(when effect (effect :bad-publicity))

src/clj/game/core/pick_counters.clj

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -202,25 +202,36 @@
202202
(not can-use-bad-pub?)))
203203
{:async true
204204
:effect pay-rest}
205-
(if (and pre-chosen (in-coll? (map :cid provider-cards) (:cid pre-chosen)))
205+
(if (and pre-chosen (or (in-coll? (map :cid provider-cards) (:cid pre-chosen))
206+
(= pre-chosen :bad-publicity)))
206207
{:async true
207-
:effect (req (let [target pre-chosen
208-
pay-credits-type (-> target card-def :interactions :pay-credits :type)
209-
pay-function (if (= :custom pay-credits-type)
210-
(-> target card-def :interactions :pay-credits :custom)
211-
(take-counters-of-type pay-credits-type))
212-
custom-ability ^:ignore-async-check {:async true
213-
:effect pay-function}
214-
neweid (make-eid state outereid)
215-
providing-card target]
216-
(wait-for (resolve-ability state side neweid custom-ability providing-card [card])
217-
(continue-ability state side
218-
(pick-credit-providing-cards
219-
provider-func eid target-count stealth-target
220-
(update selected-cards (:cid providing-card)
221-
#(assoc % :card providing-card :number (+ (:number % 0) async-result)))
222-
target)
223-
card targets))))}
208+
:effect (req
209+
(if (= target :bad-publicity)
210+
(continue-ability
211+
state side
212+
(pick-credit-providing-cards
213+
provider-func eid target-count stealth-target selected-cards (when (and (should-auto-repeat? state side)
214+
(> bad-pub-available 1))
215+
target)
216+
uses (dec bad-pub-available) (inc bad-pub-spent))
217+
card targets)
218+
(let [target pre-chosen
219+
pay-credits-type (-> target card-def :interactions :pay-credits :type)
220+
pay-function (if (= :custom pay-credits-type)
221+
(-> target card-def :interactions :pay-credits :custom)
222+
(take-counters-of-type pay-credits-type))
223+
custom-ability ^:ignore-async-check {:async true
224+
:effect pay-function}
225+
neweid (make-eid state outereid)
226+
providing-card target]
227+
(wait-for (resolve-ability state side neweid custom-ability providing-card [card])
228+
(continue-ability state side
229+
(pick-credit-providing-cards
230+
provider-func eid target-count stealth-target
231+
(update selected-cards (:cid providing-card)
232+
#(assoc % :card providing-card :number (+ (:number % 0) async-result)))
233+
target uses bad-pub-available bad-pub-spent)
234+
card targets)))))}
224235
{:async true
225236
:prompt (str "Choose a credit providing card ("
226237
counter-count (when (and target-count (pos? target-count))

src/cljs/nr/gameboard/board.cljs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1871,7 +1871,8 @@
18711871
(concat [(when offer-bad-pub?
18721872
;; TODO - translate this
18731873
[:button {:key "Bad Pub"
1874-
:on-click #(send-command "bad-pub-choice" {:eid (prompt-eid (:side @game-state))})}
1874+
:on-click #(send-command "bad-pub-choice" {:eid (prompt-eid (:side @game-state))
1875+
:shift-key-held (.-shiftKey %)})}
18751876
(str "Bad Publicity (" offer-bad-pub? " available)")])]
18761877
(doall (for [{:keys [idx uuid value]} choices
18771878
:when (not= value "Hide")]

test/clj/game/cards/events_test.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
(is (changed? [(:credit (get-runner)) -1]
5151
(click-prompt state :runner "New Angeles City Hall")
5252
(click-prompt state :runner "Yes")
53-
(select-bad-pub state 1))
53+
(select-bad-pub state nil))
5454
"Spent 1 + 1 from bad pub")
5555
(is (= 2 (:credit (get-runner))) "Runner has 2 credits left")
5656
(click-prompt state :runner "Yes")
@@ -6653,11 +6653,11 @@
66536653
;; Trashable execs
66546654
(run-empty-server state :remote2)
66556655
(click-prompt state :runner "Pay 6 [Credits] to trash")
6656-
(select-bad-pub state 1)
6656+
(select-bad-pub state nil)
66576657
(is (empty? (:scored (get-runner))) "Chairman Hiro not added to runner's score area")
66586658
(run-empty-server state "R&D")
66596659
(click-prompt state :runner "Pay 5 [Credits] to trash")
6660-
(select-bad-pub state 1)
6660+
(select-bad-pub state nil)
66616661
(is (empty? (:scored (get-runner))) "Director Haas not added to runner's score area")
66626662
(take-credits state :runner)
66636663
;; Trash RM, make sure everything works again

test/clj/game/cards/hardware_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1326,7 +1326,7 @@
13261326
(click-card state :corp "Hostile Takeover")
13271327
(run-continue state)
13281328
(card-ability state :runner (get-program state 0) 2)
1329-
(select-bad-pub state 1)
1329+
(select-bad-pub state nil)
13301330
(card-ability state :runner (get-program state 0) 2)
13311331
(card-ability state :runner (get-program state 0) 0)
13321332
(click-prompt state :runner "Gain 2 [Credits]")

test/clj/game/cards/ice_test.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8160,7 +8160,7 @@
81608160
(run-continue state)
81618161
(card-ability state :runner (get-program state 0) 0)
81628162
(click-prompt state :runner "End the run")
8163-
(select-bad-pub state 1)
8163+
(select-bad-pub state nil)
81648164
(run-continue state)
81658165
(click-prompt state :corp "Yes")
81668166
(click-card state :corp "Ice Wall")

test/clj/game/cards/upgrades_test.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,7 +2123,7 @@
21232123
(click-prompt state :runner "Take 1 tag")
21242124
(is (= 1 (count-tags state)) "Runner takes 1 tag to prevent Corp from removing 1 BP")
21252125
(click-prompt state :runner "Pay 2 [Credits] to trash") ; trash
2126-
(select-bad-pub state 1)
2126+
(select-bad-pub state nil)
21272127
(run-empty-server state "Archives")
21282128
(is (= 1 (count-bad-pub state)))
21292129
(click-prompt state :runner "The Corp removes 1 bad publicity")
@@ -4139,7 +4139,7 @@
41394139
(run-on state :remote1)
41404140
(is (changed? [(count (:hand (get-runner))) -4]
41414141
(card-ability state :runner (get-program state 0) 0)
4142-
(select-bad-pub state 0)
4142+
(select-bad-pub state nil)
41434143
(click-prompt state :corp "Yes"))
41444144
"Got slammed for 4 damage")))
41454145

test/clj/game/core/rules_test.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,17 +378,17 @@
378378
(run-empty-server state :remote1)
379379
(click-prompt state :corp "No")
380380
(click-prompt state :runner "Pay 1 [Credits] to trash")
381-
(select-bad-pub state 1)
381+
(select-bad-pub state nil)
382382
(is (= 5 (:credit (get-runner))) "1 BP credit spent to trash CVS")
383383
(run-empty-server state :hq)
384384
(click-prompt state :corp "No")
385385
(click-prompt state :runner "Pay 1 [Credits] to trash")
386-
(select-bad-pub state 1)
386+
(select-bad-pub state nil)
387387
(is (= 5 (:credit (get-runner))) "1 BP credit spent to trash CVS")
388388
(run-empty-server state :rd)
389389
(click-prompt state :corp "No")
390390
(click-prompt state :runner "Pay 1 [Credits] to trash")
391-
(select-bad-pub state 1)
391+
(select-bad-pub state nil)
392392
(is (= 5 (:credit (get-runner))) "1 BP credit spent to trash CVS")))
393393

394394
(deftest run-psi-bad-publicity-credits

test/clj/game/core/scenarios_test.clj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@
55
[game.core.card :refer :all]
66
[game.test-framework :refer :all]))
77

8+
(deftest bad-publicity-works-with-shift-key
9+
(do-game
10+
(new-game {:corp {:hand ["Scatter Field"] :bad-pub 3}
11+
:runner {:hand ["Unity"] :credits 10}})
12+
(play-cards state :corp ["Scatter Field" "HQ" :rezzed])
13+
(take-credits state :corp)
14+
(play-from-hand state :runner "Unity")
15+
(run-on state :hq)
16+
(run-continue-until state :encounter-ice)
17+
(auto-pump-and-break state (get-program state 0))
18+
(is (changed? [(:credit (get-runner)) -2]
19+
(select-bad-pub state true))
20+
"3 pub + 2cr")))
21+
822
(deftest tread-lightly-vovo-combine-well
923
(do-game
1024
(new-game {:corp {:hand ["Tithe" "Vovô Ozetti"]}

test/clj/game/test_framework.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,9 @@
231231
(click-prompt state :runner (str "Pay " cost " [Credits] to trash")))
232232

233233
(defn select-bad-pub
234-
[state expected]
235-
(core/process-action "bad-pub-choice" state :runner {:eid (:eid (get-prompt state :runner))}))
234+
[state shift-held?]
235+
(core/process-action "bad-pub-choice" state :runner {:eid (:eid (get-prompt state :runner))
236+
:shift-key-held shift-held?}))
236237

237238
;; General utilities necessary for starting a new game
238239
(defn find-card

0 commit comments

Comments
 (0)