Permalink
Browse files

Merge branch '08-detecting' into 09-problems

  • Loading branch information...
2 parents 74620ff + c59af06 commit 124870ca84adeee7e87adb1b6783abf2782ec373 @technomancy committed Apr 17, 2009
Showing with 15 additions and 7 deletions.
  1. +2 −2 src/mire.clj
  2. +11 −3 src/mire/rooms.clj
  3. +2 −2 src/mire/util.clj
View
@@ -37,5 +37,5 @@
(recur (read-line))))
(finally (cleanup))))))
-(load-rooms (str (.getParent (java.io.File. *file*)) "/../data/rooms/"))
-(defonce server (create-server port mire-handle-client))
+(set-rooms "data/rooms")
+(defonce server (create-server port mire-handle-client))
View
@@ -1,6 +1,6 @@
(ns mire.rooms)
-(def rooms)
+(declare rooms)
(defn load-room [rooms file]
(let [room (read-string (slurp (.getAbsolutePath file)))]
@@ -13,8 +13,16 @@
:inhabitants (ref #{})}})))
(defn load-rooms [dir]
- (def rooms (reduce load-room {}
- (.listFiles (java.io.File. dir)))))
+ "Given a dir, return a map with an entry corresponding to each file
+in it. Files should be maps containing room data."
+ (reduce load-room {} (.listFiles (java.io.File. dir))))
+
+(defn set-rooms
+ "Set mire.rooms/rooms to a map of rooms corresponding to each file
+ in dir. This function should be used only once at mire startup, so
+ having a def inside the function body should be OK."
+ [dir]
+ (def rooms (load-rooms dir)))
(defn room-contains?
[room thing]
View
@@ -3,5 +3,5 @@
(defn move-between-refs
"Move one instance of obj between from and to. Must be called in a transaction."
[obj from to]
- (commute from disj obj)
- (commute to conj obj))
+ (alter from disj obj)
+ (alter to conj obj))

0 comments on commit 124870c

Please sign in to comment.