       @(can-capture? conn q r)))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;; Unit Construction
+
+(deftrack buildable-unit-type-eids [conn]
+  (->> @(posh/q conn '[:find ?ut
+                       :in $ ?g
+                       :where
+                       [?g  :game/current-faction ?f]
+                       [?f  :faction/credits ?credits]
+                       [?ut :unit-type/cost ?cost]
+                       [?ut :unit-type/id ?unit-type-id]
+                       [(>= ?credits ?cost)]]
+                @(game-eid conn))
+       (map first)
+       (into [])))
+
+(deftrack buildable-unit-types [conn]
+  (->> @(buildable-unit-type-eids conn)
+       (map (fn [ut] @(posh/pull conn '[*] ut)))
+       (into [])))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Selection and Target
 
 (deftrack selected? [conn q r]

;;; Map

(deftrack game-map-eid [conn]
  (ffirst
    @(posh/q conn '[:find ?m
                    :where
                    [_  :app/game ?g]
                    [?g :game/map ?m]])))

(defn game-map [conn]
  (posh/pull conn

(deftrack terrains [conn]
  (let [map-eid' @(game-map-eid conn)]
    (:map/terrains
     @(posh/pull conn [{:map/terrains terrain-pull}]
                 map-eid'))))

(defn current-base-locations [conn]
  (posh/q conn '[:find ?q ?r
