Kibitised.

This commit is contained in:
Simon Brooke 2014-08-13 20:07:11 +01:00
parent 34d3745ecb
commit 03733f8ddf
6 changed files with 33 additions and 35 deletions

View file

@ -3115,7 +3115,7 @@ front of the sequence of tokens it returns nil.</p>
</td><td class="codes"></td></tr><tr><td class="docs"><p>Parse a number.</p>
</td><td class="codes"><pre class="brush: clojure">(defn parse-numeric-value
[[value &amp; remainder]]
(if (re-matches re-number value) [(read-string value) remainder]))</pre></td></tr><tr><td class="docs"><p>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]))</pre></td></tr><tr><td class="docs"><p>Parse a token assumed to be the name of a property of the current cell,
whose value is assumed to be an integer.</p>
</td><td class="codes"><pre class="brush: clojure">(defn parse-property-int
[[value &amp; remainder]]
@ -3217,7 +3217,7 @@ front of the sequence of tokens it returns nil.</p>
comparator (cond (= MORE &quot;more&quot;) '&gt;
(member? MORE '(&quot;fewer&quot; &quot;less&quot;)) '&lt;)]
(cond
(not (= WITHIN &quot;within&quot;))
(not= WITHIN &quot;within&quot;)
(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.</p>
(cond
(and quantity (= NEIGHBOURS &quot;neighbours&quot;))
(cond
(not (= WITHIN &quot;within&quot;))
(not= WITHIN &quot;within&quot;)
(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.</p>
</td><td class="codes"><pre class="brush: clojure">(defn- parse-arithmetic-action
[previous [prop1 SHOULD BE prop2 operator value &amp; rest]]
(cond
(member? prop2 '(&quot;x&quot; &quot;y&quot;))
(member? prop1 '(&quot;x&quot; &quot;y&quot;))
(throw
(Exception. reserved-properties-error))
(and (= SHOULD &quot;should&quot;)

View file

@ -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 &quot;inspect?x=%d&amp;y=%d&quot; (:x cell) (:y cell))}
[:a {:href (format &quot;inspect?x=%d&amp;y=%d&quot; (:x cell) (:y cell))}
[:img {:alt (:state cell) :src (format-image-path state)}]]]))</pre></td></tr><tr><td class="docs"><p>Render this world row as a Hiccup table row.</p>
</td><td class="codes"><pre class="brush: clojure">(defn render-world-row
[row]
@ -3150,14 +3150,14 @@ net.brehaut.ClojureTools = (function (SH) {
</td><td class="codes"><pre class="brush: clojure">(defn render-world-table
[]
(let [world (or (session/get :world)
(heightmap/apply-heightmap
(heightmap/apply-heightmap
(io/get-resource &quot;/img/heightmaps/small_hill.png&quot;)))
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 &quot;/rulesets/basic.txt&quot;)))
(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 &quot;Generation &quot; generation)]]))</pre></td></tr><tr><td class="docs">
[:p
(str &quot;Generation &quot; generation)]]))</pre></td></tr><tr><td class="docs"><p>Render in Hiccup format the HTML content of an inspector on this cell.</p>
</td><td class="codes"><pre class="brush: clojure">(defn render-inspector
[cell table]
[:table {:class &quot;music-ruled&quot;}
[:tr
[:td {:colspan 2 :style &quot;text-align: center;&quot;}
[:tr
[:td {:colspan 2 :style &quot;text-align: center;&quot;}
[:img {:src (str &quot;img/tiles/&quot; (name (:state cell)) &quot;.png&quot;)
: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-&gt;html (str &quot;/md/&quot; content))})))</pre></td></tr><tr><td class="docs">
</td><td class="codes"><pre class="brush: clojure">(defn list-states []
(sort
(filter #(not (nil? %))
(remove nil?
(map #(first (rest (re-matches #&quot;([0-9a-z-]+).png&quot; (.getName %))))
(file-seq (clojure.java.io/file &quot;resources/public/img/tiles&quot;))))))</pre></td></tr><tr><td class="docs">
</td><td class="codes"><pre class="brush: clojure">(defn docs-page []
@ -3318,15 +3318,14 @@ net.brehaut.ClojureTools = (function (SH) {
pause (:pause params)
rulefile (:ruleset params)
rulepath (str &quot;/rulesets/&quot; rulefile &quot;.txt&quot;)]
(if (not (= map &quot;&quot;))
(if (not= map &quot;&quot;)
(session/put! :world
(heightmap/apply-heightmap
(io/get-resource (str &quot;/img/heightmaps/&quot; map &quot;.png&quot;)))))
(if (not (= rulefile &quot;&quot;))
(do
(session/put! :rule-text (io/slurp-resource rulepath))
(session/put! :rules (compiler/compile-file (io/get-resource rulepath)))))
(if (not (= pause &quot;&quot;))
(when (not= rulefile &quot;&quot;)
(session/put! :rule-text (io/slurp-resource rulepath))
(session/put! :rules (compiler/compile-file (io/get-resource rulepath))))
(if (not= pause &quot;&quot;)
(session/put! :pause pause))
(layout/render &quot;params.html&quot;
(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)))))))</pre></td></tr><tr><td class="spacer docs">&nbsp;</td><td class="codes" /></tr></table><div class="footer">Generated by <a href="https://github.com/fogus/marginalia">Marginalia</a>.&nbsp;&nbsp;Syntax highlighting provided by Alex Gorbatchev's <a href="http://alexgorbatchev.com/SyntaxHighlighter/">SyntaxHighlighter</a></div><script type="text/javascript">SyntaxHighlighter.defaults['gutter'] = false;
SyntaxHighlighter.all()</script></body></html>

View file

@ -47,7 +47,7 @@
(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)

View file

@ -19,8 +19,8 @@
(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)]
@ -61,7 +61,7 @@
(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"))))))

View file

@ -31,15 +31,14 @@
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)

View file

@ -16,6 +16,6 @@
[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)))))))