From 03733f8ddf380b50a032508661a651ddb2d7db61 Mon Sep 17 00:00:00 2001
From: Simon Brooke
Parse a number.
(defn parse-numeric-value [[value & remainder]] - (if (re-matches re-number value) [(read-string value) remainder]))
Parse a token assumed to be the name of a property of the current cell, + (if (and value (re-matches re-number value)) [(read-string value) remainder]))
Parse a token assumed to be the name of a property of the current cell, whose value is assumed to be an integer.
(defn parse-property-int [[value & remainder]] @@ -3217,7 +3217,7 @@ front of the sequence of tokens it returns nil. comparator (cond (= MORE "more") '> (member? MORE '("fewer" "less")) '<)] (cond - (not (= WITHIN "within")) + (not= WITHIN "within") (parse-comparator-neighbours-condition (flatten ;; two tokens were mis-parsed as 'within distance' that weren't @@ -3256,7 +3256,7 @@ front of the sequence of tokens it returns nil. (cond (and quantity (= NEIGHBOURS "neighbours")) (cond - (not (= WITHIN "within")) + (not= WITHIN "within") (parse-simple-neighbours-condition (flatten ;; two tokens were mis-parsed as 'within distance' that weren't @@ -3325,7 +3325,7 @@ front of the sequence of tokens it returns nil.
(defn- parse-arithmetic-action [previous [prop1 SHOULD BE prop2 operator value & rest]] (cond - (member? prop2 '("x" "y")) + (member? prop1 '("x" "y")) (throw (Exception. reserved-properties-error)) (and (= SHOULD "should") diff --git a/resources/public/docs/mw-ui/uberdoc.html b/resources/public/docs/mw-ui/uberdoc.html index fccdf70..2ee4e5f 100644 --- a/resources/public/docs/mw-ui/uberdoc.html +++ b/resources/public/docs/mw-ui/uberdoc.html @@ -3142,7 +3142,7 @@ net.brehaut.ClojureTools = (function (SH) { [cell] (let [state (:state cell)] [:td {:class (format-css-class state) :title (format-mouseover cell)} - [:a {:href (format "inspect?x=%d&y=%d" (:x cell) (:y cell))} + [:a {:href (format "inspect?x=%d&y=%d" (:x cell) (:y cell))} [:img {:alt (:state cell) :src (format-image-path state)}]]]))
Render this world row as a Hiccup table row.
(defn render-world-row [row] @@ -3150,14 +3150,14 @@ net.brehaut.ClojureTools = (function (SH) {
(defn render-world-table [] (let [world (or (session/get :world) - (heightmap/apply-heightmap + (heightmap/apply-heightmap (io/get-resource "/img/heightmaps/small_hill.png"))) - rules (or (session/get :rules) - (do (session/put! :rules - (compiler/compile-file + rules (or (session/get :rules) + (do (session/put! :rules + (compiler/compile-file (io/get-resource "/rulesets/basic.txt"))) (session/get :rules))) - generation (+ (or (session/get :generation) 0) 1) + generation (inc (or (session/get :generation) 0)) w2 (engine/transform-world world rules) ] (session/put! :world w2) @@ -3166,13 +3166,13 @@ net.brehaut.ClojureTools = (function (SH) { (apply vector (cons :table (map render-world-row w2))) - [:p - (str "Generation " generation)]]))
Render in Hiccup format the HTML content of an inspector on this cell.
(defn render-inspector [cell table] [:table {:class "music-ruled"} - [:tr - [:td {:colspan 2 :style "text-align: center;"} + [:tr + [:td {:colspan 2 :style "text-align: center;"} [:img {:src (str "img/tiles/" (name (:state cell)) ".png") :width 64 :height 64}]]] @@ -3229,8 +3229,8 @@ net.brehaut.ClojureTools = (function (SH) { (let [params (keywordize-keys (:params request)) xs (:x params) ys (:y params) - x (if (not (empty? xs)) (read-string xs) 0) - y (if (not (empty? ys)) (read-string ys) 0) + x (if (seq xs) (read-string xs) 0) + y (if (seq ys) (read-string ys) 0) world (session/get :world) cell (engine-utils/get-cell world x y) state (:state params)] @@ -3267,7 +3267,7 @@ net.brehaut.ClojureTools = (function (SH) { :content (util/md->html (str "/md/" content))})))
(defn list-states [] (sort - (filter #(not (nil? %)) + (remove nil? (map #(first (rest (re-matches #"([0-9a-z-]+).png" (.getName %)))) (file-seq (clojure.java.io/file "resources/public/img/tiles"))))))
(defn docs-page [] @@ -3318,15 +3318,14 @@ net.brehaut.ClojureTools = (function (SH) { pause (:pause params) rulefile (:ruleset params) rulepath (str "/rulesets/" rulefile ".txt")] - (if (not (= map "")) + (if (not= map "") (session/put! :world (heightmap/apply-heightmap (io/get-resource (str "/img/heightmaps/" map ".png"))))) - (if (not (= rulefile "")) - (do - (session/put! :rule-text (io/slurp-resource rulepath)) - (session/put! :rules (compiler/compile-file (io/get-resource rulepath))))) - (if (not (= pause "")) + (when (not= rulefile "") + (session/put! :rule-text (io/slurp-resource rulepath)) + (session/put! :rules (compiler/compile-file (io/get-resource rulepath)))) + (if (not= pause "") (session/put! :pause pause)) (layout/render "params.html" (merge (send-params) @@ -3404,7 +3403,7 @@ net.brehaut.ClojureTools = (function (SH) { [path (str (io/resource-path) directory)] (session/put! :list-resources-path path) (sort - (filter #(not (nil? %)) + (remove nil? (map #(first (rest (re-matches pattern (.getName %)))) (file-seq (clojure.java.io/file path)))))))