Browse Source

Implement action queueing

Thomas Dy 9 năm trước cách đây
mục cha
commit
e231d77d15
1 tập tin đã thay đổi với 7 bổ sung0 xóa
  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))))