 (defn add-to-turn [event]
   (swap! game update-in [:turns] add-event-to-turn event))
 
-(defn do-mayor []
-  
+(defn do-mayor [cstate]
+  (swap! estream conj 
+         [:rolepick :mayor]
+         [:worker :bank -1]
+         [:worker (nth (:order cstate) (:role-picker cstate)) 1])
   )
+
+(defn action-done []
+  (swap! estream conj [:actiondone])) 
 
 (defn do-settler [field-type i]
   (when true

                        :trader "Goods for money"
                        :builder "Buy buildings"
                        :settler "Get quarry/field(s)"
                        :mayor "Get colonists"
                        :craftsman "Produce goods"})


(def common-state
  {:roles (set (keys role-descriptions))
   :goods [:coffee 9 :tobacco 9 :corn 10 :sugar 11 :indigo 11]
   :buildings common/initial-buildings
   :trader []
   :governor 0

                                 :on-click #(do-settler field i)} (name field)]
                    )
                  (:available-fields current))
     [:h3 "Governor: " (:governor cstate)]
     [:h3 "Role picker: " (:role-picker cstate)]
     [:h3 "Current role: " (str (:current-role cstate))]
     [:h3 "Action picker: " (:action-picker cstate)]
     [:button.btn.btn-success {:on-click action-done} "Done!"]
     ]))

(defn game-state []
  [:div
    [:blockquote (pr-str @estream)]
    [:blockquote (pr-str (calc-state))]])


(reagent/render-component [building-board] (.getElementById js/document "building-board"))
