Kaynağa Gözat

Implement action queueing

Thomas Dy 9 yıl önce
ebeveyn
işleme
e231d77d15
1 değiştirilmiş dosya ile 7 ekleme ve 0 silme
  1. 7 0
      src/bombnet/game.clj

+ 7 - 0
src/bombnet/game.clj

@@ -185,3 +185,10 @@
   (let [{bombs :bombs} state
         new-bombs (mapv #(update-in % [:counter] dec) bombs)]
     (assoc state :bombs new-bombs)))
+
+(defn queue-action [state id action]
+  (update-in state [:players]
+             (partial
+               mapv-if
+               #(= id (:id %))
+               #(assoc % :action action))))