                 :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)]

                     :unit-type/image (:image unit-def)
                     :unit-type/zoc-armor-types (map #(to-armor-type %) (:zoc unit-def))}]
                   (into (attack-strengths-tx db game-id unit-type-eid (:attack-strengths unit-def)))
                   (into (terrain-effects-tx db game-id unit-type-eid (:terrain-effects unit-def)))))))
          units-def)))

(defn unit-states-tx [db game-id state-map-eid state-map-name states]

    (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)))

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