Class: PfrpgCore::Specializer
- Inherits:
-
Object
- Object
- PfrpgCore::Specializer
- Defined in:
- lib/pfrpg_core/specializer.rb
Instance Attribute Summary collapse
-
#character ⇒ Object
readonly
Returns the value of attribute character.
-
#proficient_types ⇒ Object
readonly
Returns the value of attribute proficient_types.
Instance Method Summary collapse
-
#initialize(character) ⇒ Specializer
constructor
A new instance of Specializer.
- #is_proficient_in_armor?(armor) ⇒ Boolean
- #is_proficient_in_weapon?(weapon) ⇒ Boolean
- #parse_singles(feat) ⇒ Object
- #parse_types(feat) ⇒ Object
- #proficiency_strings(character) ⇒ Object
- #read_str(str) ⇒ Object
Constructor Details
#initialize(character) ⇒ Specializer
Returns a new instance of Specializer.
4 5 6 7 |
# File 'lib/pfrpg_core/specializer.rb', line 4 def initialize(character) @character = character @proficient_types = proficiency_strings(character) end |
Instance Attribute Details
#character ⇒ Object (readonly)
Returns the value of attribute character.
3 4 5 |
# File 'lib/pfrpg_core/specializer.rb', line 3 def character @character end |
#proficient_types ⇒ Object (readonly)
Returns the value of attribute proficient_types.
3 4 5 |
# File 'lib/pfrpg_core/specializer.rb', line 3 def proficient_types @proficient_types end |
Instance Method Details
#is_proficient_in_armor?(armor) ⇒ Boolean
44 45 46 |
# File 'lib/pfrpg_core/specializer.rb', line 44 def is_proficient_in_armor?(armor) proficient_types[:types].include? armor.weight_class end |
#is_proficient_in_weapon?(weapon) ⇒ Boolean
39 40 41 42 |
# File 'lib/pfrpg_core/specializer.rb', line 39 def is_proficient_in_weapon?(weapon) return true if weapon.weapon_type == 'natural' proficient_types[:types].include?(weapon.weapon_type) || proficient_types[:singles].include?(weapon.name) end |
#parse_singles(feat) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/pfrpg_core/specializer.rb', line 27 def parse_singles(feat) if feat.effects && feat.effects['SINGLE'] feat.special elsif feat.effects && feat.effects['GROUP'] read_str(feat.effects) end end |
#parse_types(feat) ⇒ Object
21 22 23 24 25 |
# File 'lib/pfrpg_core/specializer.rb', line 21 def parse_types(feat) if feat.effects && feat.effects['TYPE'] read_str(feat.effects) end end |
#proficiency_strings(character) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/pfrpg_core/specializer.rb', line 9 def proficiency_strings(character) proficient_items = { :types => [], :singles => [] } prof_feats = character.feats.select { |x| x.name['Proficiency'] } prof_feats.each do |feat| proficient_items[:types] << parse_types(feat) proficient_items[:singles] << parse_singles(feat) end proficient_items[:types] = proficient_items[:types].flatten proficient_items[:singles] = proficient_items[:singles].flatten proficient_items end |
#read_str(str) ⇒ Object
35 36 37 |
# File 'lib/pfrpg_core/specializer.rb', line 35 def read_str(str) str.split(':')[1].split(';')[0] end |