                               (when (= (:counter card) 0) (trash state :corp card)))}]}
 
    "Project Junebug"
-   {:advanceable :always
-    :access {:optional {:prompt "Pay 1 [Credits] to use Project Junebug ability?"
-                        :req (req (and installed (> (:credit corp) 0)))
-                        :yes-ability {:cost [:credit 1] :msg (msg "do " (* 2 (get card :advance-counter 0)) " net damage")
-                                      :effect (effect (damage :net (* 2 (get card :advance-counter 0)) {:card card}))}}}}
+   (advance-ambush 1 {:msg (msg "do " (* 2 (:advance-counter card 0)) " net damage")
+                      :effect (effect (damage :net (* 2 (:advance-counter card 0))
+                                              {:card card}))})
 
    "Psychic Field"
    (let [ab {:psi {:req (req installed)

    :events {:corp-turn-begins {:msg "gain 1 [Credits]" :effect (effect (gain :credit 1))}}}

   "Plan B"
   {:advanceable :always
    :access {:optional
             {:prompt "Score an Agenda from HQ?"
              :req (req installed)
              :yes-ability {:effect (req (let [c card]
                                           (resolve-ability
                                             state side
                                             {:prompt "Choose an Agenda in HQ to score"
                                              :choices {:req #(and (is-type? % "Agenda")
                                                                   (<= (:advancementcost %) (:advance-counter c))
                                                                   (in-hand? %))}
                                              :msg (msg "score " (:title target))
                                              :effect (effect (score (assoc target :advance-counter
                                                                                   (:advancementcost target))))} c nil)))}}}}

   "Primary Transmission Dish"
   {:recurring 3}


(in-ns 'game.core)

;;; Asset-specific helpers
(defn installed-access-trigger
  "Effect for triggering ambush on access. 
  Ability is what happends upon access. If cost is specified Corp needs to pay that to trigger."
  ([cost ability]
   (let [ab (if (> cost 0) (assoc ability :cost [:credit cost]) ability)
         prompt (if (> cost 0)
                  (req (str "Pay " cost " [Credits] to use " (:title card) " ability?"))
                  (req (str "Use " (:title card) " ability?")))]
     (installed-access-trigger cost ab prompt)))
  ([cost ability prompt]
   {:access {:req (req (and installed (>= (:credit corp) cost)))
             :effect (effect (show-wait-prompt :runner (str "Corp to use " (:title card)))
                             (resolve-ability
                              {:optional
                               {:prompt prompt
                                :yes-ability ability
                                :end-effect (effect (clear-wait-prompt :runner))}}
                              card nil))}}))

(defn advance-ambush
  "Creates advanceable ambush structure with specified ability for specified cost"
  ([cost ability] (assoc (installed-access-trigger cost ability) :advanceable :always))
  ([cost ability prompt] (assoc (installed-access-trigger cost ability prompt)
                           :advanceable :always)))

(defn campaign
  "Creates a Campaign with X counters draining Y per-turn.
