diff --git a/src/mire/player.clj b/src/mire/player.clj index 2549ab7..491acdd 100644 --- a/src/mire/player.clj +++ b/src/mire/player.clj @@ -1,5 +1,4 @@ -(ns mire.player - (:use [clojure.contrib.seq-utils])) +(ns mire.player) (def *current-room*) (def *inventory*) @@ -10,4 +9,4 @@ (defn carrying? [thing] - (includes? @*inventory* (keyword thing))) \ No newline at end of file + (some #{@*inventory*} (keyword thing))) diff --git a/src/mire/rooms.clj b/src/mire/rooms.clj index 4078a79..724fc65 100644 --- a/src/mire/rooms.clj +++ b/src/mire/rooms.clj @@ -1,6 +1,6 @@ (ns mire.rooms) -(declare rooms) +(def rooms {}) (defn load-room [rooms file] (let [room (read-string (slurp (.getAbsolutePath file)))] @@ -12,19 +12,17 @@ :items (ref (or (:items room) #{})) :inhabitants (ref #{})}}))) -(defn load-rooms [dir] +(defn load-rooms "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)))) + in it. Files should be maps containing room data." + [rooms dir] + (reduce load-room rooms (.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. Defaults to - looking in data/rooms/." - ([dir] - (def rooms (load-rooms dir))) - ([] (set-rooms "data/rooms/"))) +(defn add-rooms + "Look through all the files in a dir for files describing rooms and add + them to the mire.rooms/rooms map." + [dir] + (alter-var-root #'rooms load-rooms dir)) (defn room-contains? [room thing] diff --git a/src/mire/util.clj b/src/mire/util.clj deleted file mode 100644 index 46e0406..0000000 --- a/src/mire/util.clj +++ /dev/null @@ -1,7 +0,0 @@ -(ns mire.util) - -(defn move-between-refs - "Move one instance of obj between from and to. Must be called in a transaction." - [obj from to] - (alter from disj obj) - (alter to conj obj)) \ No newline at end of file