Class: PfrpgReaders::Filters::ProficiencyMod
- Inherits:
-
Object
- Object
- PfrpgReaders::Filters::ProficiencyMod
- Defined in:
- lib/pfrpg_readers/filters/proficiency_mod.rb
Instance Attribute Summary collapse
-
#character ⇒ Object
readonly
Returns the value of attribute character.
Instance Method Summary collapse
- #filter(attack) ⇒ Object
-
#initialize(character) ⇒ ProficiencyMod
constructor
A new instance of ProficiencyMod.
- #modify_for_armor(attack, armor) ⇒ Object
- #modify_for_weapon(attack) ⇒ Object
Constructor Details
#initialize(character) ⇒ ProficiencyMod
Returns a new instance of ProficiencyMod.
5 6 7 |
# File 'lib/pfrpg_readers/filters/proficiency_mod.rb', line 5 def initialize(character) @character = character end |
Instance Attribute Details
#character ⇒ Object (readonly)
Returns the value of attribute character.
4 5 6 |
# File 'lib/pfrpg_readers/filters/proficiency_mod.rb', line 4 def character @character end |
Instance Method Details
#filter(attack) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pfrpg_readers/filters/proficiency_mod.rb', line 9 def filter(attack) proficiency = Specializer.new(character) unless proficiency.is_proficient_in_weapon? attack.weapon modify_for_weapon(attack) end armor = character.armor_and_shield armor.each do |a| unless proficiency.is_proficient_in_armor? a modify_for_armor(attack, a) end end end |
#modify_for_armor(attack, armor) ⇒ Object
27 28 29 30 31 |
# File 'lib/pfrpg_readers/filters/proficiency_mod.rb', line 27 def modify_for_armor(attack, armor) attack.filter_str << "Not proficient with armor: #{armor.name}" # armor check penalties are negative attack.other_bonus += NullObject.maybe(armor.armor_check_penalty) end |
#modify_for_weapon(attack) ⇒ Object
22 23 24 25 |
# File 'lib/pfrpg_readers/filters/proficiency_mod.rb', line 22 def modify_for_weapon(attack) attack.filter_str << 'Not proficient with weapon, -4 atk' attack.other_bonus -= 4 end |