Skip to content

Commit 8d73e15

Browse files
committed
fire an 'all-subs-broken' event when encountering 0-sub ice
1 parent fcfb97c commit 8d73e15

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/clj/game/core/ice.clj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,7 @@
185185
(defn all-subs-broken?
186186
[ice]
187187
(let [subroutines (:subroutines ice)]
188-
(and (seq subroutines)
189-
(every? :broken subroutines))))
188+
(every? :broken subroutines)))
190189

191190
(defn any-subs-broken-by-card?
192191
[ice card]

src/clj/game/core/runs.clj

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[game.core.engine :refer [checkpoint end-of-phase-checkpoint register-pending-event pay queue-event resolve-ability trigger-event trigger-event-simult]]
1111
[game.core.flags :refer [can-run? cards-can-prevent? clear-run-register! get-prevent-list prevent-jack-out]]
1212
[game.core.gaining :refer [gain-credits]]
13-
[game.core.ice :refer [active-ice? get-current-ice get-run-ices update-ice-strength reset-all-ice reset-all-subs! set-current-ice]]
13+
[game.core.ice :refer [active-ice? break-subs-event-context get-current-ice get-run-ices update-ice-strength reset-all-ice reset-all-subs! set-current-ice]]
1414
[game.core.mark :refer [is-mark?]]
1515
[game.core.payment :refer [build-cost-string build-spend-msg can-pay? merge-costs ->c]]
1616
[game.core.prompts :refer [clear-run-prompts clear-wait-prompt show-run-prompts show-prompt show-wait-prompt]]
@@ -334,10 +334,15 @@
334334
(checkpoint state side eid)))))})
335335

336336
(defn encounter-ice
337+
;; note: as far as I can tell, this deliberately leaves on open eid (the run eid).
338+
;; Attempting to change that breaks a very large number of tests, so I'm leaving this
339+
;; note here to remind me when I look at this later. -nbk, 2025
337340
[state side eid ice]
338341
(swap! state update :encounters conj {:eid eid
339342
:ice ice})
340343
(check-auto-no-action state)
344+
;; step 6.9.3a: The encounter begins. Conditions relating to the Runner encountering
345+
;; this ice are met (this is on-encounter effects, etc)
341346
(let [on-encounter (:on-encounter (card-def ice))
342347
applied-encounters (get-effects state nil :gain-encounter-ability ice)
343348
all-encounters (map #(preventable-encounter-abi % ice) (remove nil? (conj applied-encounters on-encounter)))]
@@ -349,8 +354,16 @@
349354
(make-eid state)
350355
{:cancel-fn (fn [state]
351356
(should-end-encounter? state side ice))})
352-
(when (should-end-encounter? state side ice)
353-
(encounter-ends state side eid)))))
357+
(if (should-end-encounter? state side ice)
358+
(encounter-ends state side eid)
359+
;; step 6.9.3b: if there are no subroutines on the ice,
360+
;; the runner is considered to have broken all the subroutines on this ice.
361+
;; This should fire an event, so it can get picked up with cards like hippo
362+
;; or knifed.
363+
(when-let [c-ice (get-current-ice state)]
364+
(when (and (same-card? c-ice ice) (zero? (count (:subroutines c-ice))))
365+
(wait-for (trigger-event-simult state side :subroutines-broken nil (break-subs-event-context state c-ice [] (get-in @state [:runner :basic-action-card]))))))))))
366+
354367

355368
(defmethod start-next-phase :encounter-ice
356369
[state side _]

0 commit comments

Comments
 (0)