# HG changeset patch # User Steve Losh # Date 1342667750 14400 # Node ID 6e92c8d8ddacdbfc90ddecda180aa111f9b40210 # Parent f57db9d7ccffed8a76b6ccfbaf89a191ff351b00 Add death messages. diff -r f57db9d7ccff -r 6e92c8d8ddac src/caves/entities/aspects/destructible.clj --- a/src/caves/entities/aspects/destructible.clj Wed Jul 18 17:42:43 2012 -0400 +++ b/src/caves/entities/aspects/destructible.clj Wed Jul 18 23:15:50 2012 -0400 @@ -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)))