       :game/self-repair (:self-repair settings-def)
       :game/move-through-friendly (:move-through-friendly settings-def)}]))
 
-(defn build-terrains-tx [db game-id terrain-type-id can-build-def]
-  (let [game (game-by-id db game-id)]
-    (into []
-          (map
-           (fn [unit-type-name]
-             {:db/id (db/next-temp-id)
-              :terrain-type/_can-build terrain-type-id
-              :terrain-build/unit-type (e (find-by db :unit-type/id (to-unit-type-id unit-type-name)))}))
-          can-build-def)))
-
 (defn terrain-types-tx [db game-id terrains-def]
   (let [game (game-by-id db game-id)]
     (into []

    (d/transact! conn (terrain-types-tx @conn game-id (:terrains ruleset)))
    (d/transact! conn (unit-state-map-tx @conn game-id (:unit-state-maps ruleset)))
    (d/transact! conn (unit-types-tx @conn game-id (:units ruleset)))
    (d/transact! conn (terrain-can-build-tx @conn game-id (:terrains ruleset)))

    ;; Map and bases
    (d/transact! conn (game-map-tx @conn game-id (map-defs map-id)))

                :terrain-effect/attack-bonus attack-bonus
                :terrain-effect/armor-bonus armor-bonus})))
          terrain-effects-def)))

(defn terrain-build-tx [db game-id unit-type-eid buildable-at-def]
  (let [game (game-by-id db game-id)]
    (into []
          (map
           (fn [terrain-type-name]
             (let [terrain-type-idx (->> terrain-type-name to-terrain-type-id (game-id-idx game-id))]
               {:db/id (db/next-temp-id)
                :terrain-type/_can-build [:terrain-type/game-id-idx terrain-type-idx]
                :terrain-can-build/unit-type unit-type-eid})))
          buildable-at-def)))

(defn unit-types-tx [db game-id units-def]
  (let [game (game-by-id db game-id)]
