Class: PfrpgRaces::Race

Inherits:
Object
  • Object
show all
Defined in:
lib/pfrpg_races/race.rb

Direct Known Subclasses

Dwarf, Human, Elf, Gnome, HalfElf, HalfOrc, Halfling

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.fetch(race_str) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/pfrpg_races/race.rb', line 4

def self.fetch(race_str)
  begin
    return Object::const_get(race_str).new
  rescue Exception
    return nil
  end
end

.race_listObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/pfrpg_races/race.rb', line 12

def self.race_list
  [
    Dwarf.new,
    Human.new,
    Gnome.new,
    HalfElf.new,
    Elf.new,
    HalfOrc.new,
    Halfling.new
  ]
end

Instance Method Details

#as_json(options = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/pfrpg_races/race.rb', line 44

def as_json(options={})
  {
    :name => name,
    :description => description,
    :languages => languages,
    :int_languages => int_languages,
    :speed => speed,
    :size => size,
    :weapons => weapon_familiarity,
    :attributes => attributes,
    :traits => traits,
    :source => source
  }
end

#attributesObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pfrpg_races/race.rb', line 32

def attributes
  if attribute_bonuses == nil
    return "You will later get to choose a +2 bonus to one ability score of your choice"
  else
    str = ""
    attribute_bonuses.each do |a|
      str += "#{a.to_s}, "
    end
    return str
  end
end

#bonus_featsObject



28
29
30
# File 'lib/pfrpg_races/race.rb', line 28

def bonus_feats
  []
end

#size_modifierObject



24
25
26
# File 'lib/pfrpg_races/race.rb', line 24

def size_modifier
  PfrpgTables::Tables::Size.get_size_modifier(size)
end