Hi Ben,

if I understand it correctly, your program shows completely normal 
behavior: you instantiate your Sword class and assign a number to 
@realDam and then just read this variable 5 times. What you might want 
is this:

class Sword
	def intialize(maxDam)
		@maxDam = maxDam
	end
	def realDam
		return rand(@maxDam) + 1
	end
end

So everytime you access sword_instance.realDam you get a freshly 
calculated random number which is never higher than @maxDam. Since 
everything is a method call in ruby (even accessing an instance 
variable), there is no need to declare one (in your special case 
however), the realDam method behaves like a getter.

Hope that helps,
Martin


Ben Galyean wrote:
> Hello all,
> 
> Just started my first Ruby prog and hit a snag almost instantly. I
> simply wish to have my selected weapon do it's prescribed damage as I
> intend (in this case, it's 1-8 damage). Complete noob here so any help
> at all would be greatly appreciated. The following is a re-creation of
> my problem:
> 
> #***********************************
> class Sword
> attr_accessor(:realDam)
> 
>   def initialize(aRealDam)
>       @realDam = aRealDam
>   end
> end
> 
> Longsword = Sword.new(rand(8)+1)
> weapon = Longsword
> 
> begin
> 
> 5.times {p weapon.realDam}
> puts
> 5.times {p  (rand(8)+1)}
> 
> end
> #*************************************
> 
> Output looks like this:
> 
> #****Current Longsword damage (Picks a number and 'keeps' it).****
> 6
> 6
> 6
> 6
> 6
> 
> #****Intended output for the longsword here****
> 6
> 8
> 8
> 4
> 8