Permalink
Browse files

Add death messages.

  • Loading branch information...
sjl committed Jul 19, 2012
1 parent 8607f68 commit da9206cb32d99c461c196b89c778450d34280262
Showing with 7 additions and 2 deletions.
  1. +7 −2 src/caves/entities/aspects/destructible.clj
@@ -1,12 +1,17 @@
(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)))

0 comments on commit da9206c

Please sign in to comment.