Skip to content

Commit

Permalink
Refactor reset-variable-subs to make 0 index reset explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
butzopower committed Nov 12, 2023
1 parent 73cce9d commit 5e40c9f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/clj/game/cards/ice.clj
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@
(:variable %))
(:subroutines card))
new-card (assoc card :subroutines old-subs)
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-subs (if (pos? total)
(->> (range total)
(reduce (fn [ice _] (add-sub ice sub (:cid ice) args)) new-card)
:subroutines
(into []))
(into [] (map-indexed (fn [idx sub] (assoc sub :index idx)) (:subroutines new-card))))
new-card (assoc new-card :subroutines new-subs)]
(update! state :corp new-card)
(trigger-event state side :subroutines-changed (get-card state new-card)))))
Expand All @@ -91,7 +92,6 @@
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

0 comments on commit 5e40c9f

Please sign in to comment.