Permalink
Browse files

Mire: detector

  • Loading branch information...
1 parent a62d254 commit 43d7e88c53abdf0f5bd1448731d567888a0e25b8 @apauley committed Dec 28, 2009
Showing with 11 additions and 0 deletions.
  1. +1 −0 PeepCode/Clojure/mire/data/rooms/hallway
  2. +10 −0 PeepCode/Clojure/mire/src/mire/commands.clj
View
1 PeepCode/Clojure/mire/data/rooms/hallway
@@ -1,3 +1,4 @@
{:desc "You are in a long, low-lit hallway that turns to the east."
+ :items #{:detector}
:exits {:north :start,
:east :promenade}}
View
10 PeepCode/Clojure/mire/src/mire/commands.clj
@@ -44,6 +44,15 @@
"See what you are carrying"
(str-join "\n " (conj @*inventory* "You are carrying:")))
+(defn detect [item]
+ "If you have the detector, you can see which room an item is in."
+ (if (@*inventory* :detector)
+ (if-let [room (first (filter #((:items %) (keyword item))
+ (vals rooms)))]
+ (str item " is in " (:name room))
+ (str item " is not in any room."))
+ "You need to be carrying the detector for that."))
+
(def commands
{:move move,
:north #(move :north),
@@ -54,6 +63,7 @@
:grab grab,
:discard discard,
:inventory inventory,
+ :detect detect,
:wtf #(str "You need help.")})
(defn execute

0 comments on commit 43d7e88

Please sign in to comment.