src/caves/entities/aspects/attacker.clj @ ef03fb8bb7e4
Add real hp, attack and defense.
author |
Steve Losh <steve@stevelosh.com> |
date |
Sun, 15 Jul 2012 15:24:14 -0400 |
parents |
180b5b981d92 |
children |
811f328099c6 |
(ns caves.entities.aspects.attacker
(:use [caves.entities.aspects.destructible :only [Destructible take-damage
defense-value]]
[caves.entities.core :only [defaspect]]))
(defaspect Attacker
(attack [this world target]
{:pre [(satisfies? Destructible target)]}
(let [damage (inc (rand-int (max 0 (- (attack-value this world)
(defense-value target world)))))]
(take-damage target world damage)))
(attack-value [this world]
(get this :attack 1)))