src/caves/entities/bunny.clj @ ef03fb8bb7e4

Add real hp, attack and defense.
author Steve Losh <steve@stevelosh.com>
date Sun, 15 Jul 2012 15:24:14 -0400
parents 130e2fc7c495
children 811f328099c6
(ns caves.entities.bunny
  (:use [caves.entities.core :only [Entity get-id add-aspect]]
        [caves.entities.aspects.destructible :only [Destructible]]
        [caves.entities.aspects.mobile :only [Mobile move can-move?]]
        [caves.world :only [find-empty-neighbor]]))


(defrecord Bunny [id glyph color location hp max-hp])

(defn make-bunny [location]
  (map->Bunny {:id (get-id)
               :glyph "v"
               :color :yellow
               :location location
               :hp 4
               :max-hp 4}))


(extend-type Bunny Entity
  (tick [this world]
    (if-let [target (find-empty-neighbor world (:location this))]
      (move this world target)
      world)))

(add-aspect Bunny Mobile)
(add-aspect Bunny Destructible)