      (when-let [leave-effect (:leave-play (card-def card))]
        (when (or (= (:side card) "Runner") (:rezzed card))
          (leave-effect state side card nil)))
+     (when-let [prevent (:prevent (card-def card))]
+               (doseq [dtype prevent]
+                      (swap! state update-in [:damage :prevent dtype]
+                             (fn [pv] (remove #(= (:cid %) (:cid card)) pv)))))
      (unregister-events state side card)
      (when-let [mu (:memoryunits card)]
        (gain state :runner :memory mu))

      (register-events state side
                       {(if (= side :corp) :corp-turn-begins :runner-turn-begins)
                        {:effect (effect (set-prop card :counter recurring))}} c))
    (update! state side c)
    (resolve-ability state side cdef c nil)
    (when-let [events (:events cdef)] (register-events state side events c))
    (get-card state c)))

(defn damage-count [state side dtype n]
  (max 0 (if-let [bonus (get-in @state [:special :damage-bonus dtype])]
                 (+ n bonus) n)))

(defn damage-bonus [state side dtype n]
      ;(system-msg state side (str (+ n (get-in state [:special :damage-bonus dtype]))))
  (swap! state update-in [:special :damage-bonus dtype] (fnil #(+ % n) 0)))
(defn flatline [state]
  (system-msg state :runner "is flatlined"))

(defn damage [state side type n]
  (trigger-event state side :pre-damage type)
  (let [n (damage-count state side type n) hand (get-in @state [:runner :hand])]
       (system-msg state side (str n " " type))
    (when (< (count hand) n)
      (flatline state))
    (when (= type :brain)
      (swap! state update-in [:runner :brain-damage] #(+ % n))
      (swap! state update-in [:runner :max-hand-size] #(- % n)))
    (doseq [c (take n (shuffle hand))]
      (trash state side c type))
    (trigger-event state side :damage type))
  (swap! state update-in [:special :damage-bonus] dissoc type))

(defn shuffle! [state side kw]
  (swap! state update-in [side kw] shuffle))


(defn runner-install
  ([state side card] (runner-install state side card nil))
  ([state side {:keys [title type cost memoryunits uniqueness prevent] :as card} {:keys [extra-cost no-cost]}]
     (let [dest [:rig (to-keyword type)]
           cost (if no-cost 0 cost)]
       (when (and (or (not uniqueness) (not (in-play? state card)))
