瀏覽代碼

Implement action queueing

Thomas Dy 9 年之前
父節點
當前提交
e231d77d15
共有 1 個文件被更改,包括 7 次插入0 次删除
  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))))