   [state]
   (swap! state
          (fn [current]
-           (let [{:keys [game-state start-time]} current]
-             (if (timeup? start-time)
-               (assoc current :state :finished)
-               current)))))
+           (let [{:keys [game-state start-time inventory]} current]
+             (assoc current :game-state
+                    (cond
+                      (enough-bones? inventory) :win
+                      (timeup? start-time) :lose
+                      :else game-state))))))
 
 (defn handle-keyevent
   [state keyevent]
-  (.log js/console "you pressed:" keyevent)
-  (log-state @state)
-  (move-player state keyevent))
+  (move-player state keyevent)
+  (log-state @state))
 
 (defn translate-keyboard-event
   [e]

(def cell-size 32)
(def aspectRatio (float (/ 4 3)))
(def time-limit 10)

(defn abs
  [number]

  [(pixels->cell (/ game-width 2))
   (- (pixels->cell game-height) 1)])

(defn random-location
  []
  (map (comp int rand) [(inc game-x-cells) game-y-cells]))

(defn random-item-spawns
  [item number]
  (into {}
        (map #(vector % item) (take number (repeatedly random-location)))))

(defn random-spawns
  []
  (merge (random-item-spawns :flask 5)
         (random-item-spawns :bones 30)))

(defn initial-state
  []
  {:start-time (js/Date.)
   :game-state :playing
   :item-locations (random-spawns)
   :inventory []
   :player start-position} )

(def keycode->key
