class CharacterBuilder

Attributes

age[W]
gender[W]
name[W]
p_class[W]
race[W]

Public Class Methods

new() click to toggle source
# File lib/D_D_Character_Gen.rb, line 3
def initialize
  p_class
  race
  gender
  age
  name
end

Public Instance Methods

age() click to toggle source
# File lib/D_D_Character_Gen.rb, line 27
def age 
  if @race=="elf" 
    then @age=(rand(15..150))
  elsif @race=="human"
    then @age=(rand(15..50))
  elsif @race=="wizard"
    then @age=(rand(15..130))
  elsif @race=="gnome"
    then @age=(rand(15..130))
  elsif @race=="dwarf"
    then @age=(rand(15..90))
  elsif @race=="halfling" 
    then @age=(rand(15..100))
  elsif @race=="half-orc" 
    then @age=(rand(15..120))
  end
end
gender() click to toggle source
# File lib/D_D_Character_Gen.rb, line 13
def gender
  @gender=["male","female"].sample
end
p_class() click to toggle source
# File lib/D_D_Character_Gen.rb, line 10
def p_class
  @p_class=["rogue", "wizard", "fighter", "cleric"].sample
end
race() click to toggle source
# File lib/D_D_Character_Gen.rb, line 16
def race
 if @p_class=="fighter"
    then @race=["dwarf", "human","gnome"].sample
 elsif @p_class=="wizard"
    then @race=["halfling", "elf","human"].sample
 elsif @p_class=="cleric"
    then @race=["elf", "halfling","half-orc"].sample
 elsif @p_class=="rogue"
    then @race=["elf", "half-orc","human"].sample
 end
end
to_s() click to toggle source
# File lib/D_D_Character_Gen.rb, line 44
def to_s
    "Hello #{@name}: You are a #{@gender} #{@race} #{@p_class}, aged #{@age}. \n"
end