Class: PfrpgImport::HeroclassFacts

Inherits:
Object
  • Object
show all
Includes:
CaseHelpers
Defined in:
lib/pfrpg_import/heroclass_facts.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from CaseHelpers

#arrayify, #camelized_title, #underscored_title

Constructor Details

#initialize(bundle) ⇒ HeroclassFacts

Returns a new instance of HeroclassFacts.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pfrpg_import/heroclass_facts.rb', line 8

def initialize(bundle)
  @friendly_name = bundle[:heroclass_name]
  @hit_die       = bundle[:hit_die].gsub("d","")
  @start_wealth  = bundle[:starting_wealth]
  @starting_wealth_average = bundle[:starting_wealth_avg]
  @alignment     = bundle[:alignment]
  @skills_per_level = bundle[:skills_per]
  @spells_bonus_attr = bundle[:spell_mod]
  @description   = bundle[:description]
  @class_skills  = bundle[:class_skills]
  @starting_feats= bundle[:starting_feats]
  @feature_type  = get_feature_type(@friendly_name)
end

Instance Attribute Details

#alignmentObject (readonly)

Returns the value of attribute alignment.



4
5
6
# File 'lib/pfrpg_import/heroclass_facts.rb', line 4

def alignment
  @alignment
end

#class_skillsObject (readonly)

Returns the value of attribute class_skills.



4
5
6
# File 'lib/pfrpg_import/heroclass_facts.rb', line 4

def class_skills
  @class_skills
end

#descriptionObject (readonly)

Returns the value of attribute description.



4
5
6
# File 'lib/pfrpg_import/heroclass_facts.rb', line 4

def description
  @description
end

#feature_typeObject (readonly)

Returns the value of attribute feature_type.



4
5
6
# File 'lib/pfrpg_import/heroclass_facts.rb', line 4

def feature_type
  @feature_type
end

#friendly_nameObject (readonly)

Returns the value of attribute friendly_name.



4
5
6
# File 'lib/pfrpg_import/heroclass_facts.rb', line 4

def friendly_name
  @friendly_name
end

#hit_dieObject (readonly)

Returns the value of attribute hit_die.



4
5
6
# File 'lib/pfrpg_import/heroclass_facts.rb', line 4

def hit_die
  @hit_die
end

#skills_per_levelObject (readonly)

Returns the value of attribute skills_per_level.



4
5
6
# File 'lib/pfrpg_import/heroclass_facts.rb', line 4

def skills_per_level
  @skills_per_level
end

#spells_bonus_attrObject (readonly)

Returns the value of attribute spells_bonus_attr.



4
5
6
# File 'lib/pfrpg_import/heroclass_facts.rb', line 4

def spells_bonus_attr
  @spells_bonus_attr
end

#start_wealthObject (readonly)

Returns the value of attribute start_wealth.



4
5
6
# File 'lib/pfrpg_import/heroclass_facts.rb', line 4

def start_wealth
  @start_wealth
end

#starting_featsObject (readonly)

Returns the value of attribute starting_feats.



4
5
6
# File 'lib/pfrpg_import/heroclass_facts.rb', line 4

def starting_feats
  @starting_feats
end

#starting_wealth_avgObject (readonly)

Returns the value of attribute starting_wealth_avg.



4
5
6
# File 'lib/pfrpg_import/heroclass_facts.rb', line 4

def starting_wealth_avg
  @starting_wealth_avg
end

Instance Method Details

#alignment_stringObject



93
94
95
96
97
98
99
100
# File 'lib/pfrpg_import/heroclass_facts.rb', line 93

def alignment_string
  case @alignment
  when 'any'
    return 'Alignment.any'
  else
    return 'Alignment.any'
  end
end

#feats_stringObject



168
169
170
171
172
173
174
# File 'lib/pfrpg_import/heroclass_facts.rb', line 168

def feats_string
  str = ""
  @starting_feats.split(",").each do |feat|
    str += "\'#{feat}',"
  end
  return str
end

#get_feature_type(friendly_name) ⇒ Object



26
27
28
# File 'lib/pfrpg_import/heroclass_facts.rb', line 26

def get_feature_type(friendly_name)
  "#{camelized_title(friendly_name)}Feature"
end

#get_skill_class(skill) ⇒ Object



146
147
148
# File 'lib/pfrpg_import/heroclass_facts.rb', line 146

def get_skill_class(skill)
  camelized_title(skill)
end


84
85
86
87
88
89
90
91
# File 'lib/pfrpg_import/heroclass_facts.rb', line 84

def print_alignment
  <<-eos
  def alignment
#{alignment_string}
  end

  eos
end


57
58
59
60
61
62
63
64
# File 'lib/pfrpg_import/heroclass_facts.rb', line 57

def print_bonuses_for_level
  <<-eos
  def bonuses_for_level(level)
PfrpgTables::Heroclasses::#{@friendly_name}.level_bonus(level)
  end

  eos
end


75
76
77
78
79
80
81
82
# File 'lib/pfrpg_import/heroclass_facts.rb', line 75

def print_create_feature
  <<-eos
  def create_feature(f)
#{@feature_type}.new(:ability_name => f)
  end

  eos
end


120
121
122
123
124
125
126
127
# File 'lib/pfrpg_import/heroclass_facts.rb', line 120

def print_description
  <<-eos
  def description
"#{@description}"
  end

  eos
end


150
151
152
153
154
155
156
157
# File 'lib/pfrpg_import/heroclass_facts.rb', line 150

def print_feature_type
  <<-eos
  def feature_type
"#{feature_type}"
  end

  eos
end


39
40
41
42
43
44
45
46
# File 'lib/pfrpg_import/heroclass_facts.rb', line 39

def print_hit_die
  <<-eos
  def hit_die
Dice.new(1,#{@hit_die})
  end

  eos
end


30
31
32
33
34
35
36
37
# File 'lib/pfrpg_import/heroclass_facts.rb', line 30

def print_name
  <<-eos
  def name
"#{@friendly_name}"
  end

  eos
end


129
130
131
132
133
134
135
136
# File 'lib/pfrpg_import/heroclass_facts.rb', line 129

def print_skills
  <<-eos
  def skills
[ #{skills_string} ]
  end

  eos
end


102
103
104
105
106
107
108
109
# File 'lib/pfrpg_import/heroclass_facts.rb', line 102

def print_skills_per_level
  <<-eos
  def skills_per_level
#{@skills_per_level}
  end

  eos
end


111
112
113
114
115
116
117
118
# File 'lib/pfrpg_import/heroclass_facts.rb', line 111

def print_spells_bonus_attr
  <<-eos
  def spells_bonus_attr
"#{@spells_bonus_attr}"
  end

  eos
end


66
67
68
69
70
71
72
73
# File 'lib/pfrpg_import/heroclass_facts.rb', line 66

def print_spells_per_day
  <<-eos
  def get_spells_table(level)
PfrpgTables::Spells::SpellsPerDay.#{@friendly_name}(level)
  end

  eos
end


159
160
161
162
163
164
165
166
# File 'lib/pfrpg_import/heroclass_facts.rb', line 159

def print_starting_feats
  <<-eos
  def starting_feats
[ #{feats_string} ]
  end

  eos
end


48
49
50
51
52
53
54
55
# File 'lib/pfrpg_import/heroclass_facts.rb', line 48

def print_starting_wealth
  <<-eos
  def starting_wealth
Dice.new(5,6, multiplier = 10)
  end

  eos
end

#skills_stringObject



138
139
140
141
142
143
144
# File 'lib/pfrpg_import/heroclass_facts.rb', line 138

def skills_string
  str = ""
  @class_skills.split(',').each do |s|
    str = str + "Skill::#{get_skill_class(s)}.new, "
  end
  str
end

#titleObject



22
23
24
# File 'lib/pfrpg_import/heroclass_facts.rb', line 22

def title
  @friendly_name.underscore
end