Class: PfrpgRaces::Race

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

Direct Known Subclasses

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

Defined Under Namespace

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.fetch(race_str) ⇒ Object



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

def self.fetch(race_str)
  begin
    race_str = "PfrpgRaces::Race::#{race_str}" unless race_str['PfrpgRaces::Race']
    return Object::const_get(race_str).new
  rescue Exception
    return nil
  end
end

.race_listObject



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

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

Instance Method Details

#as_json(options = {}) ⇒ Object



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

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



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

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



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

def bonus_feats
  []
end

#size_modifierObject



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

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