From: Ruairidh Mchardy Date: 2008-11-04T03:49:13+09:00 Subject: Re: Text Based RPG in Ruby Matthew Moss wrote: >> end >> randy = rand(100) >> health = Grunto.hp - randy >> puts "Grunty's hp is #{Health}" >> end > > > First, did you mean Grunto.hp or Grunty.hp? > > Second, even if you meant Grunty.hp, I do not think that means what > you think that means. > > Third, if you meant @hp instead of Grunty.hp, then why even bother > checking if == 0 since you just assigned 100 to it? Hi, Just modified my code a little and now have: Grunty = Grunt.new(100, 300, 300, "Ak47") randy = rand(100) Health = Grunt.hp - randy puts "Grunty is battling a kitten!" puts "The kitten attacks Grunty with an AK47 and inflicts #{randy} points of damage!" puts "Grunty lost #{randy} health!" puts "Grunty's hp is #{Health} " So Grunty is my monster and I'm checking the starting vars from the Grunt class, then subtracting hitpoints from a random value. So perhaps I should do my checks of if Grunt.hp == 0 then blah in the attack class? Attached is my (albeit messy) code so far! Hugh, Very true in regards to learning from others, I just feel that I couldn't emulate that coding style as I don't understand it sufficiently. It's very frustrating! Thanks for the help guys! Kind Regards, Ruairidh McHardy -- Posted via http://www.ruby-forum.com/.