       (and capturing (= capture-round (:game/round game)))
       (into (end-turn-capture-tx db game unit)))))
 
-(defn end-turn-tx [db game]
+(defn end-turn-tx
+  "Return a transaction that completes captures, clears per round unit flags,
+  updates the current faction, adds faction credits, and updates the round."
+  [db game]
   (let [starting-faction (qe '[:find ?f
                                :in $ ?g
                                :where

    (catch :default ex
      false)))

;; Capture
;; x check unit can capture
;; x check base capturable
;; x set state to capturing
;; x set capture round

(defn capture-tx
  ([db game unit]
   (let [base (base-at db game (:unit/q unit) (:unit/r unit))
         round (:game/round game)]

      :unit/q to-q
      :unit/r to-r}]))

;; TODO: check move is valid
(defn move-tx
  "Returns a transaction that updates the unit's location and move count."
  ([db game unit to-terrain]
   (let [new-move-count (inc (get unit :unit/move-count 0))
         [to-q to-r] (terrain-hex to-terrain)]
     (check-can-move db game unit)
     [{:db/id (e unit)
       :unit/game-pos-idx (game-pos-idx game to-q to-r)
       :unit/q to-q
