Permalink
Browse files

Hear the bats chirping. Worked. Tested.

  • Loading branch information...
Tuan Nguyen
Tuan Nguyen committed Aug 8, 2011
1 parent d46eefe commit 3594d53b996b1d95ead919a0edbdfe13ec9964a8
@@ -20,4 +20,7 @@
(should= true (hazard? "wumpus"))
(should= true (hazard? :wumpus)))
+ (it "knows that bats is a hazard"
+ (should= true (hazard? "bats"))
+ (should= true (hazard? :bats)))
)
@@ -37,6 +37,7 @@
(->
(new-game :caverns (donut-map))
(place-hazard :wumpus 1)
+ (place-hazard :bats 2)
(place-player "Thor" 5)))
(it "reports no detected wumpus"
@@ -46,6 +47,10 @@
(let [game (place-player @game "Thor" 2)]
(should= ["You smell the Wumpus."] (hazard-report game "Thor"))))
+ (it "reports detected bats"
+ (let [game (place-player @game "Thor" 3)]
+ (should= ["You hear chirping."] (hazard-report game "Thor"))))
+
(it "reports death by wumpus"
(let [game (place-player @game "Thor" 1)]
(should= ["You were killed by the Wumpus."] (game-over-report game "Thor"))))
@@ -2,7 +2,7 @@
(:use
[hunt-the-wumpus.model.player :only (player-location)]))
-(def hazards #{:wumpus})
+(def hazards #{:wumpus :bats})
(defn hazard? [thing]
(not (nil? (some hazards [(keyword thing)]))))
@@ -12,6 +12,3 @@
(defn hazard-locations [game hazard]
(get-in game [:hazards hazard]))
-
-
-
@@ -26,6 +26,8 @@
(defmulti report-hazard identity)
(defmethod report-hazard :wumpus [hazard]
"You smell the Wumpus.")
+(defmethod report-hazard :bats [hazard]
+ "You hear chirping.")
(defn- hazards-adjacent-to [game origin]
(let [adjacent-caverns (set (vals (get (:caverns game) origin)))

0 comments on commit 3594d53

Please sign in to comment.