 (defn derez [state side card]
   (system-msg state side (str "derez " (:title card)))
   (update! state :corp (desactivate state :corp card true))
+  (when-let [derez-effect (:derez-effect (card-def card))]
+    (resolve-ability state side derez-effect (get-card state card) nil))
   (trigger-event state side :derez card))
 
 (defn advance [state side {:keys [card]}]

  (let [server (first (get-in @state [:run :server]))]
    (swap! state update-in [:runner :register :unsuccessful-run] #(conj % server))
    (swap! state assoc-in [:run :unsuccessful] true)
    (trigger-event state side :unsuccessful-run)
    (handle-end-run state side)))

(defn no-action [state side args]
  (swap! state assoc-in [:run :no-action] true)
  (system-msg state side "has no further action"))

(defn continue [state side args]
  (when (get-in @state [:run :no-action])
    (swap! state update-in [:run :position] dec)
    (swap! state assoc-in [:run :no-action] false)
    (swap! state assoc-in [:runner :rig :program]
           (for [p (get-in @state [:runner :rig :program])]
             (if (or (not (:current-strength p)) (:all-run p))
               p (assoc p :current-strength nil))))
    (system-msg state side "continues the run")))

(defn play-ability [state side {:keys [card ability targets] :as args}]
  (let [cdef (card-def card)

              (resolve-ability state side end-run-effect (:card run-effect) [(first server)]))))
        (swap! state assoc :run nil))))

(declare update-ice-strength)

(defn add-prop [state side card key n]
  (update! state side (update-in card [key] #(+ (or % 0) n)))
  (when (= key :advance-counter)
    (trigger-event state side :advance card)
    (when (and (#{"ICE"} (:type card)) (:rezzed card)) (update-ice-strength state side card))))

(defn set-prop [state side card & args]
  (update! state side (apply assoc (cons card args))))
