Skip to content
This repository has been archived by the owner on Oct 21, 2021. It is now read-only.

Commit

Permalink
Upgrade player and rooms namespaces to Clojure 1.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Apr 24, 2010
1 parent 8dd4a5d commit 1326451
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
5 changes: 2 additions & 3 deletions src/mire/player.clj
@@ -1,5 +1,4 @@
(ns mire.player
(:use [clojure.contrib.seq-utils]))
(ns mire.player)

(def *current-room*)
(def *inventory*)
Expand All @@ -10,4 +9,4 @@

(defn carrying?
[thing]
(includes? @*inventory* (keyword thing)))
(some #{@*inventory*} (keyword thing)))
22 changes: 10 additions & 12 deletions 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)))]
Expand All @@ -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]
Expand Down
7 changes: 0 additions & 7 deletions src/mire/util.clj

This file was deleted.

0 comments on commit 1326451

Please sign in to comment.