src/caves/entities/bunny.clj @ 1a3a4f8d5d85

Refactor the world code into separate files.

This pulls out the world generation code into its own file.  It was
getting a bit crowded in there.
author Steve Losh <steve@stevelosh.com>
date Wed, 01 Aug 2012 21:13:37 -0400
parents f57db9d7ccff
children (none)
(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]]
        [caves.world.core :only [find-empty-neighbor]]))


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

(defn make-bunny [location]
  (map->Bunny {:id (get-id)
               :name "bunny"
               :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 target world)
      world)))

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