Skip to content

Commit

Permalink
Merge pull request mtgred#3872 from jwarwick/mutate
Browse files Browse the repository at this point in the history
Fix crash in Mutate when installing in empty remote with one ice.
  • Loading branch information
nealterrell authored Sep 24, 2018
2 parents d3d85a0 + 6b853f0 commit a745526
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/clj/game/cards/operations.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@
(system-msg state side (str "reveals " (clojure.string/join ", " titles) " from R&D")))
(if-let [ice (first r)]
(let [newice (assoc ice :zone (:zone target) :rezzed true)
ices (get-in @state (cons :corp (:zone target)))
ices (get-in @state (cons :corp (:zone target)) [])
newices (apply conj (subvec ices 0 i) newice (subvec ices i))]
(swap! state assoc-in (cons :corp (:zone target)) newices)
(swap! state update-in [:corp :deck] (fn [coll] (remove-once #(= (:cid %) (:cid newice)) coll)))
Expand Down
19 changes: 18 additions & 1 deletion test/clj/game_test/cards/operations.clj
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,24 @@
(play-from-hand state :corp "Mutate")
(click-card state :corp (get-ice state :hq 0))
(is (empty? (get-ice state :hq)) "No ice installed")
(is (second-last-log-contains? state "Hedge Fund") "Skipped card name was logged"))))
(is (second-last-log-contains? state "Hedge Fund") "Skipped card name was logged")))
(testing "Remote server"
(do-game
(new-game (default-corp ["Mutate" "Ice Wall" "Enigma" "Hedge Fund"])
(default-runner))
(core/move state :corp (find-card "Hedge Fund" (:hand (get-corp))) :deck)
(core/move state :corp (find-card "Enigma" (:hand (get-corp))) :deck)
(play-from-hand state :corp "Ice Wall" "New remote")
(core/rez state :corp (get-ice state :remote1 0))
(is (= 1 (count (get-ice state :remote1))) "1 ice installed")
(is (= "Ice Wall" (:title (get-ice state :remote1 0))) "Ice Wall is installed")
(play-from-hand state :corp "Mutate")
(click-card state :corp (get-ice state :remote1 0))
(is (= 1 (count (get-ice state :remote1))) "1 ice installed")
(is (= "Enigma" (:title (get-ice state :remote1 0))) "Enigma is installed")
(is (:rezzed (get-ice state :remote1 0)) "Enigma is rezzed")
(is (second-last-log-contains? state "Hedge Fund") "Skipped card name was logged")
(is (second-last-log-contains? state "Enigma") "Installed card name was logged"))))

(deftest neural-emp
;; Neural EMP - Play if Runner made a run the previous turn to do 1 net damage
Expand Down

0 comments on commit a745526

Please sign in to comment.