    :quarry 8
    :fields {:coffee 8 :tobacco 9 :corn 10 :sugar 11 :indigo 12}})
 
+(defn bank-buildings []
+  (into {}
+        (for [[bname bdesc] common/initial-buildings]
+          [bname (select-keys bdesc [:count :column])])))
+
+(swap! estream conj
+       [:good :bank :coffee 9]
+       [:good :bank :tobacco 9]
+       [:good :bank :corn 10]
+       [:good :bank :sugar 11]
+       [:good :bank :indigo 11]
+       
+       [:field :bank :quarry 8]
+       [:field :bank :coffee 8]
+       [:field :bank :tobacco 9]
+       [:field :bank :corn 10]
+       [:field :bank :sugar 11]
+       [:field :bank :indigo 12]
+       
+       [:building :bank (bank-buildings)]
+       
+       )
+
+(defn next-player [current-picker cstate]
+  (mod (inc current-picker) (:nplayers cstate)))
+
+(defmulti transition identity)
+(defmethod transition :good [etype state [dest good-type amount]]
+  (update-in state [dest etype good-type] + amount))
+(defmethod transition :field [etype state [dest good-type amount]]
+  (update-in state [dest etype good-type] + amount))
+(defmethod transition :worker [etype state [dest amount]]
+  (update-in state [dest etype] + amount))
+(defmethod transition :vp [etype state [dest amount]]
+  (update-in state [dest etype] + amount))
+(defmethod transition :gold [etype state [dest amount]]
+  (update-in state [dest etype] + amount))
+(defmethod transition :building [etype state [dest buildings]]
+  (assoc-in state [dest] buildings))
+(defmethod transition :add-player [etype state [pname]]
+  (-> state
+      (update-in [:order] conj pname)
+      (update-in [:nplayers] inc)
+      (assoc-in [pname] {:name pname :worker 0 :gold 0 :vp 0 :field {} :building {}})))
+
+(defmethod transition :rolepick [etype state [role]]
+  (assoc state :current-role role))
+
+(defmethod transition :actiondone [etype state]
+  (update-in state [:action-picker] next-player state))
+
+(defmethod transition :default [etype state]
+  state)
+
+
+(defn calc-state []
+  (let [estream @estream]
+    (reduce 
+      (fn [acc [etype & eargs]]
+        (transition etype acc eargs))
+      {:order []
+       :nplayers 0
+       :governor 0
+       :role-picker 0
+       :current-role nil
+       :action-picker 0
+       :bank {:vp 0
+              :field-count 0
+              :building nil}}
+        estream)))
+
+(defn get-players [state]
+  (into {}
+        (remove (fn [[k v]] (keyword? k)) state)))
+
 (defn create-game
   ([p1 p2 p3]
+   (swap! estream conj
+          [:vp :bank 75]
+          [:worker :bank 55]
+          
+          [:worker :worker-ship 3]
+          [:worker :bank -3]
+          
+          [:ship 0 4]
+          [:ship 1 5]
+          [:ship 2 6]
+          
+          [:add-player p1]
+          [:gold p1 2]
+          [:field p1 :indigo 1]
+          
+          [:add-player p2]
+          [:gold p2 2]
+          [:field p2 :indigo 1]
+          
+          [:add-player p3]
+          [:gold p3 1]
+          [:field p3 :corn 1]
+          )
+   
    (merge common-state
           {:n-player 3
-           :vp 75 :colonists 55 :ships [4 5 6]
-           :colonist-ship 3
            :players [(create-player p1 2 :indigo)
                      (create-player p2 2 :indigo)
                      (create-player p3 1 :corn)]})))
 
 (def game (atom (apply create-game ["Kanwei" "Lauren" "Ted"])))
 
-(defn randomize-fields []
+(defn randomize-fields [state]
   (->> (for [[field-type field-num] (:fields @game)]
          (repeat field-num field-type))
        flatten

   [:div.box {:class type}]
   [:div.clearfix]])

(defn player-board [player]
  [:div
   (if (:role player)
     [:div.rolecard (name (:role player))])
   [:div.well
    [:div.pull-left (:name player)]
    [:span.pull-right (gold (:gold player))]
    [:span.pull-right (vp (:vp player))]
    [:div.clearfix]
    [:h5 "Buildings"]
    (for [building (:buildings player)]
      [:div (:name building)])
    [:h5 "Fields"]
    (for [field (:fields player)]
      [:div.field {:class (name field)} (name field)])
    ]])

(defn player-boards []
  [:div.row
   (for [player (:players @game)]
     [:div.col-md-3
      (player-board player)])])



(enable-console-print!)

(def estream (atom []))

(defn create-player [name gold starting-field]
  {:name name
