Class: PfrpgReaders::Filters::RangedAttackMod
- Inherits:
-
Object
- Object
- PfrpgReaders::Filters::RangedAttackMod
- Defined in:
- lib/pfrpg_readers/filters/ranged_attack_mod.rb
Instance Attribute Summary collapse
-
#character ⇒ Object
readonly
Returns the value of attribute character.
Instance Method Summary collapse
- #filter(attack) ⇒ Object
-
#initialize(character) ⇒ RangedAttackMod
constructor
A new instance of RangedAttackMod.
- #modify_attack_for_ranged_attack(attack, dex, str) ⇒ Object
Constructor Details
#initialize(character) ⇒ RangedAttackMod
Returns a new instance of RangedAttackMod.
5 6 7 |
# File 'lib/pfrpg_readers/filters/ranged_attack_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/ranged_attack_mod.rb', line 4 def character @character end |
Instance Method Details
#filter(attack) ⇒ Object
9 10 11 12 13 |
# File 'lib/pfrpg_readers/filters/ranged_attack_mod.rb', line 9 def filter(attack) unless character.feats.find { |x| x.name == 'Weapon Finesse' } modify_attack_for_ranged_attack(attack, character.dex_mod, character.str_mod) end end |
#modify_attack_for_ranged_attack(attack, dex, str) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/pfrpg_readers/filters/ranged_attack_mod.rb', line 15 def modify_attack_for_ranged_attack(attack, dex, str) begin ranged = attack.range.to_i if !(ranged == nil || ranged == '' || ranged == 0) attack.filter_str << "Range Bonus: -#{dex}, +#{str}" attack.other_bonus += dex attack.other_bonus -= str end rescue Exception => e end end |