On Tue, 4 Nov 2008, Ruairidh Mchardy wrote:

> Argh ok having problems with this. My code has just become very messy 
> because I can't get my head clear on this one.
> 
> I'm trying to structure the enemy classes as per your advice and so have 
> Grunty laid out in a manner similar to this:
> 
> class Grunty < Enemy
>  def initialize(hp,attack, defense, weapon)
>     super(hp, attack, defense)
>     @weapon = "AK47"
>     @hp =100
>     if Grunto.hp  == 0
>   puts "Grunty is dead!"
> else
>   puts "Grunty is wounded but can still fight!"
> end
> randy = rand(100)
> health = Grunto.hp - randy
> puts "Grunty's hp is #{Health}"
> end
> 
> This throws up no errors and although the hit assignment is poor, it 
> remains functional.

Excuse me blundering into this thread, but you may find:

http://blog.jayfields.com/2008/07/ruby-dwemthys-array-using-modules.html

and its associated links interesting reading.

        HTH 
        Hugh