   [state side type n {:keys [unpreventable unboostable card] :as args}]
   (swap! state update-in [:damage :defer-damage] dissoc type)
   (trigger-event state side :pre-resolve-damage type card n)
-  (let [n (if (get-defer-damage state side type args) 0 n)]
-    (let [hand (get-in @state [:runner :hand])]
-      (when (< (count hand) n)
-        (flatline state))
-      (when (= type :brain)
-        (swap! state update-in [:runner :brain-damage] #(+ % n))
-        (swap! state update-in [:runner :hand-size-modification] #(- % n)))
-      (doseq [c (take n (shuffle hand))]
-        (trash state side c {:unpreventable true :cause type} type))
-      (trigger-event state side :damage type card))))
+  (when-not (get-in @state [:damage :damage-replace])
+    (let [n (if (get-defer-damage state side type args) 0 n)]
+      (let [hand (get-in @state [:runner :hand])]
+        (when (< (count hand) n)
+          (flatline state))
+        (when (= type :brain)
+          (swap! state update-in [:runner :brain-damage] #(+ % n))
+          (swap! state update-in [:runner :hand-size-modification] #(- % n)))
+        (doseq [c (take n (shuffle hand))]
+          (trash state side c {:unpreventable true :cause type} type))
+        (trigger-event state side :damage type card)))))
 
 (defn damage
   "Attempts to deal n damage of the given type to the runner. Starts the

                 (let [prevent (get-in @state [:damage :damage-prevent type])]
                   (system-msg state :runner
                               (if prevent
                                 (str "prevents " (if (= prevent Integer/MAX_VALUE) "all" prevent )
                                      " " (name type) " damage")
                                 "will not prevent damage"))
                   (resolve-damage state side type (max 0 (- n (or prevent 0))) args)))
               {:priority 10}))
         (resolve-damage state side type n args))))))


;;; Tagging

   (swap! state update-in [:damage :damage-bonus] dissoc type)
   (swap! state update-in [:damage :damage-prevent] dissoc type)
   ;; alert listeners that damage is about to be calculated.
   (trigger-event state side :pre-damage type card n)
   (let [n (damage-count state side type n args)]
     (let [prevent (get-in @state [:prevent :damage type])]
       (if (and (not unpreventable) prevent (pos? (count prevent)))
