|
@@ -27,8 +27,6 @@
|
|
(defn get-cell [board entity]
|
|
(defn get-cell [board entity]
|
|
(let [[x y] (get-pos entity)] (get-in board [y x])))
|
|
(let [[x y] (get-pos entity)] (get-in board [y x])))
|
|
|
|
|
|
-(defn new-player [id] {:id id :pos [1 1] :color "red"})
|
|
|
|
-
|
|
|
|
(defn move-player
|
|
(defn move-player
|
|
([p x y] (assoc p :pos [x y]))
|
|
([p x y] (assoc p :pos [x y]))
|
|
([p dir]
|
|
([p dir]
|
|
@@ -39,10 +37,15 @@
|
|
"left" (move-player p (- x 1) y)
|
|
"left" (move-player p (- x 1) y)
|
|
"right" (move-player p (+ x 1) y)))))
|
|
"right" (move-player p (+ x 1) y)))))
|
|
|
|
|
|
-(defn new-game []
|
|
|
|
- {:board (new-board 21 17)
|
|
|
|
- :players []
|
|
|
|
- :bombs []})
|
|
|
|
|
|
+(defn new-game [players]
|
|
|
|
+ (let [w 21 h 17
|
|
|
|
+ colors ["red" "blue" "green" "yellow"]
|
|
|
|
+ positions [[1 1] [1 (- h 2)] [(- w 2) 1] [(- w 2) (- h 2)]]
|
|
|
|
+ positioned-players (mapv #(assoc % :pos %2 :color %3) players positions colors)]
|
|
|
|
+ {:board (new-board 21 17)
|
|
|
|
+ :players positioned-players
|
|
|
|
+ :bombs []
|
|
|
|
+ :explosion #{}}))
|
|
|
|
|
|
(defn with-action [typ]
|
|
(defn with-action [typ]
|
|
(fn [p] (= typ (get-in p [:action :type]))))
|
|
(fn [p] (= typ (get-in p [:action :type]))))
|