Commits

Steve Losh  committed 6e92c8d

Add death messages.

  • Participants
  • Parent commits f57db9d
  • Tags entry-06

Comments (0)

Files changed (1)

File src/caves/entities/aspects/destructible.clj

 (ns caves.entities.aspects.destructible
-  (:use [caves.entities.core :only [defaspect]]))
+  (:use [caves.entities.core :only [defaspect]]
+        [caves.entities.aspects.receiver :only [send-message-nearby]]))
 
 
 (defaspect Destructible
   (take-damage [{:keys [id] :as this} damage world]
     (let [damaged-this (update-in this [:hp] - damage)]
       (if-not (pos? (:hp damaged-this))
-        (update-in world [:entities] dissoc id)
+        (let [world (update-in world [:entities] dissoc id)
+              world (send-message-nearby (:location this)
+                                         (format "The %s dies." (:name this))
+                                         world)]
+          world)
         (assoc-in world [:entities id] damaged-this))))
   (defense-value [this world]
     (get this :defense 0)))