|
10 | 10 | [game.core.engine :refer [checkpoint end-of-phase-checkpoint register-pending-event pay queue-event resolve-ability trigger-event trigger-event-simult]] |
11 | 11 | [game.core.flags :refer [can-run? cards-can-prevent? clear-run-register! get-prevent-list prevent-jack-out]] |
12 | 12 | [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]] |
14 | 14 | [game.core.mark :refer [is-mark?]] |
15 | 15 | [game.core.payment :refer [build-cost-string build-spend-msg can-pay? merge-costs ->c]] |
16 | 16 | [game.core.prompts :refer [clear-run-prompts clear-wait-prompt show-run-prompts show-prompt show-wait-prompt]] |
|
334 | 334 | (checkpoint state side eid)))))}) |
335 | 335 |
|
336 | 336 | (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 |
| 340 | + ;; |
| 341 | + ;; TODO: rewrite forced encounter to use it's own version of encounter-ice, |
| 342 | + ;; then we can close the eids on this. Right now, closing the eids breaks |
| 343 | + ;; forced encounters and nothing else. |
337 | 344 | [state side eid ice] |
338 | 345 | (swap! state update :encounters conj {:eid eid |
339 | 346 | :ice ice}) |
340 | 347 | (check-auto-no-action state) |
| 348 | + ;; step 6.9.3a: The encounter begins. Conditions relating to the Runner encountering |
| 349 | + ;; this ice are met (this is on-encounter effects, etc) |
341 | 350 | (let [on-encounter (:on-encounter (card-def ice)) |
342 | 351 | applied-encounters (get-effects state nil :gain-encounter-ability ice) |
343 | 352 | all-encounters (map #(preventable-encounter-abi % ice) (remove nil? (conj applied-encounters on-encounter)))] |
|
349 | 358 | (make-eid state) |
350 | 359 | {:cancel-fn (fn [state] |
351 | 360 | (should-end-encounter? state side ice))}) |
352 | | - (when (should-end-encounter? state side ice) |
353 | | - (encounter-ends state side eid))))) |
| 361 | + (if (should-end-encounter? state side ice) |
| 362 | + (encounter-ends state side eid) |
| 363 | + ;; step 6.9.3b: if there are no subroutines on the ice, |
| 364 | + ;; the runner is considered to have broken all the subroutines on this ice. |
| 365 | + ;; This should fire an event, so it can get picked up with cards like hippo |
| 366 | + ;; or knifed. |
| 367 | + (when-let [c-ice (get-current-ice state)] |
| 368 | + (when (and (same-card? c-ice ice) (zero? (count (:subroutines c-ice)))) |
| 369 | + (wait-for |
| 370 | + (trigger-event-simult state side :subroutines-broken nil (break-subs-event-context state c-ice [] (get-in @state [:runner :basic-action-card]))) |
| 371 | + (when (should-end-encounter? state side ice) |
| 372 | + (encounter-ends state side eid))))))))) |
354 | 373 |
|
355 | 374 | (defmethod start-next-phase :encounter-ice |
356 | 375 | [state side _] |
|
375 | 394 | (if (and (not (:run @state)) |
376 | 395 | (empty? (:encounters @state))) |
377 | 396 | (forced-encounter-cleanup state :runner eid) |
378 | | - (do (when (and new-state (= new-state (get-in @state [:run :phase]))) |
379 | | - (set-phase state old-state)) |
380 | | - (effect-completed state side eid))))))) |
| 397 | + (do |
| 398 | + (when (and new-state (= new-state (get-in @state [:run :phase]))) |
| 399 | + (set-phase state old-state)) |
| 400 | + (set-current-ice state) |
| 401 | + (effect-completed state side eid))))))) |
381 | 402 |
|
382 | 403 | (defmethod continue :encounter-ice |
383 | 404 | [state side _] |
|
0 commit comments