Skip to content

Commit

Permalink
Fix indexes on printed subs when ice loses all variables subs
Browse files Browse the repository at this point in the history
  • Loading branch information
butzopower committed Nov 11, 2023
1 parent b8f6ba9 commit 9ccc040
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/clj/game/cards/ice.clj
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
new-subs (->> (range total)
(reduce (fn [ice _] (add-sub ice sub (:cid ice) args)) new-card)
:subroutines
(map-indexed (fn [idx sub] (assoc sub :index idx)))
(into []))
new-card (assoc new-card :subroutines new-subs)]
(update! state :corp new-card)
Expand All @@ -90,6 +91,7 @@
new-subs (->> (range total)
(reduce (fn [ice _] (add-sub ice sub (:cid ice) args)) card)
:subroutines
(map-indexed (fn [idx sub] (assoc sub :index idx)))
(into []))
new-card (assoc card :subroutines new-subs)]
(update! state :corp new-card)
Expand Down
14 changes: 14 additions & 0 deletions test/clj/game/cards/ice_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2052,6 +2052,20 @@
(is (empty? (:discard (get-corp))))
(is (not (:run @state)) "Run ended")))

(deftest envelopment-only-one-trash-sub-on-run
;; Envelopment should only have one trash subroutine after running out of counters
(do-game
(new-game {:corp {:hand ["Envelopment"] :credits 10}})
(play-from-hand state :corp "Envelopment" "HQ")
(rez state :corp (get-ice state :hq 0))
(take-credits state :corp)
(dotimes [_ 4]
(take-credits state :runner)
(take-credits state :corp))
(run-on state :hq)
(run-continue state)
(is (= 1 (count (:subroutines (get-ice state :hq 0)))))))

(deftest excalibur
;; Excalibur - Prevent Runner from making another run this turn
(do-game
Expand Down

0 comments on commit 9ccc040

Please sign in to comment.