src/caves/entities/aspects/destructible.clj @ 180b5b981d92
use the black magic everywhere
author |
Steve Losh <steve@stevelosh.com> |
date |
Sat, 14 Jul 2012 14:32:49 -0400 |
parents |
716b6b7e09f1 |
children |
c1fba0f3ec5f |
(ns caves.entities.aspects.destructible
(:use [caves.entities.core :only [defaspect]]))
(defaspect Destructible
(take-damage [{:keys [id] :as this} world damage]
(let [damaged-this (update-in this [:hp] - damage)]
(if-not (pos? (:hp damaged-this))
(update-in world [:entities] dissoc id)
(update-in world [:entities id] assoc damaged-this)))))