                               [(not= ?f ?cf)]]
                        @(current-faction-eid conn)))
       0))
-
-;; TODO: move to units section?
-;; TODO: sort by cost
-(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 [])))
-
-;; TODO: move to units section?
-(deftrack buildable-unit-types [conn]
-  (->> @(buildable-unit-type-eids conn)
-       (map (fn [ut] @(posh/pull conn '[*] ut)))
-       (into [])))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Units

(ns zetawar.subs
  (:require
    [datascript.core :as d]
    [zetawar.db :refer [e qe]]
    [zetawar.game :as game]
    [zetawar.hex :as hex]
    [zetawar.util :refer [select-values spy]]
    [posh.core :as posh]
    [reagent.core :as r])
  (:require-macros
    [zetawar.subs :refer [deftrack]]))

;; TODO: add asserts to check params for better error messages?


;;; 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
