Permalink
Browse files

Mire: Start moving nowhere

  • Loading branch information...
1 parent 0b5f246 commit c16838ed653364bd55c9275ba3beecc07561fe69 @apauley committed Dec 19, 2009
Showing with 14 additions and 4 deletions.
  1. +6 −1 PeepCode/Clojure/mire/src/mire/commands.clj
  2. +8 −3 PeepCode/Clojure/mire/src/mire/rooms.clj
@@ -5,7 +5,12 @@
(defn move
"We gotta get out of this place... Give a direction."
[direction]
- (str "You are trying to go " direction))
+ (let [target-name ((:exits *current-room*) (keyword direction))
+ target (rooms target-name)]
+ (if target
+ (do (set-current-room target)
+ (look))
+ "No way")))
(defn look []
"Get a description of the current room"
@@ -1,5 +1,10 @@
(ns mire.rooms)
-(def *current-room*
- {:desc "You don't know where you are. You can't see anything."
- :exits {:nowhere "You can run but you can't hide..."}})
+(def rooms
+ {:start {:desc "You don't know where you are. You can't see anything."
+ :exits {:nowhere :start}}})
+
+(defn set-current-room [target]
+ (def *current-room* (rooms :start)))
+
+(set-current-room :start)

0 comments on commit c16838e

Please sign in to comment.