                             (when (or wanted (not infaction))
                               (let [influence (* (:factioncost card) (:qty line))]
                                 [:span.influence
-                                 {:class (-> card :faction .toLowerCase (.replace " " "-"))
+                                 {:class (faction-label card)
                                   :dangerouslySetInnerHTML
                                   #js {:__html (str (if-not infaction (apply str (for [_ (range influence)] "&#9679;")))
                                                     (if wanted (apply str (for [_ (range (:qty line))] "&#9675;"))))}}]))])


(defn valid? [{:keys [identity cards] :as deck}]
  (and (>= (card-count cards) (:minimumdecksize identity))
       (<= (influence deck) (influencelimit identity))
       (every? #(and (allowed? (:card %) identity)
                     (<= (:qty %) (or (get-in % [:card :limited]) 3))) cards)
       (or (= (:side identity) "Runner")

(defn found? [query cards]
  (some #(if (= (.toLowerCase (:title %)) query) %) cards))

(defn influencelimit [identity]
  "Returns influence limit of an identity or INFINITY in case of draft IDs."
  (if (= (:setname identity) "Draft") INFINITY (:influencelimit identity)))

(defn mostwanted? [card]
  "Returns true if card is on Most Wanted NAPD list."
  (let [napdmwl '("Cerberus \"Lady\" H1" "Clone Chip" "Desperado" "Parasite" "Prepaid VoicePAD"
                   "Architect" "AstroScript Pilot Program" "Eli 1.0" "NAPD Contract" "SanSan City Grid")]
    (some #(= (:title card) %) napdmwl)))

(defn noinfcost? [identity card]
  (or (= (:faction card) (:faction identity))
      (zero? (:factioncost card)) (= INFINITY (influencelimit identity))))

(defn search [query cards]
  (filter #(if (= (.indexOf (.toLowerCase (:title %)) query) -1) false true) cards))
