src/caves/entities/aspects/destructible.clj @ 811f328099c6

Real attacking, and some refactoring.
author Steve Losh <steve@stevelosh.com>
date Tue, 17 Jul 2012 23:22:14 -0400
parents ef03fb8bb7e4
children 6e92c8d8ddac
(ns caves.entities.aspects.destructible
  (:use [caves.entities.core :only [defaspect]]))


(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)
        (assoc-in world [:entities id] damaged-this))))
  (defense-value [this world]
    (get this :defense 0)))