Class: PfrpgCore::Attack
- Inherits:
-
Object
- Object
- PfrpgCore::Attack
- Includes:
- Filterable
- Defined in:
- lib/pfrpg_core/attack.rb
Instance Attribute Summary collapse
-
#bab ⇒ Object
Returns the value of attribute bab.
-
#base_bonus ⇒ Object
Returns the value of attribute base_bonus.
-
#critical_dmg ⇒ Object
Returns the value of attribute critical_dmg.
-
#critical_range ⇒ Object
Returns the value of attribute critical_range.
-
#damage ⇒ Object
Returns the value of attribute damage.
-
#filter_str ⇒ Object
Returns the value of attribute filter_str.
-
#macros ⇒ Object
Returns the value of attribute macros.
-
#other_bonus ⇒ Object
Returns the value of attribute other_bonus.
-
#range ⇒ Object
Returns the value of attribute range.
-
#size ⇒ Object
Returns the value of attribute size.
-
#strength_bonus ⇒ Object
Returns the value of attribute strength_bonus.
-
#weapon ⇒ Object
Returns the value of attribute weapon.
-
#weapon_bonus ⇒ Object
Returns the value of attribute weapon_bonus.
-
#weapon_name ⇒ Object
Returns the value of attribute weapon_name.
-
#weapon_type ⇒ Object
Returns the value of attribute weapon_type.
-
#weight_class ⇒ Object
Returns the value of attribute weight_class.
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
- #attack_bonus ⇒ Object
- #get_damage ⇒ Object
-
#initialize(args) ⇒ Attack
constructor
A new instance of Attack.
Methods included from Filterable
Constructor Details
#initialize(args) ⇒ Attack
Returns a new instance of Attack.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pfrpg_core/attack.rb', line 10 def initialize(args) @weapon_name = args[:weapon_name] @range = args[:range] @weight_class = args[:weight_class] @damage = args[:damage] @weapon_type = args[:weapon_type] @critical_range = args[:critical_range] @critical_dmg = args[:critical_dmg] @weapon_bonus = args[:bonus] # bonus from weapon @strength_bonus = args[:strength_bonus] @bab = args[:bab] @size = args[:size] @filters = args[:filters] @filter_str = [] @weapon = args[:weapon] @macros = args[:macros] @other_bonus = 0 # things like weapon spec, training, etc apply_filters end |
Instance Attribute Details
#bab ⇒ Object
Returns the value of attribute bab.
5 6 7 |
# File 'lib/pfrpg_core/attack.rb', line 5 def bab @bab end |
#base_bonus ⇒ Object
Returns the value of attribute base_bonus.
5 6 7 |
# File 'lib/pfrpg_core/attack.rb', line 5 def base_bonus @base_bonus end |
#critical_dmg ⇒ Object
Returns the value of attribute critical_dmg.
5 6 7 |
# File 'lib/pfrpg_core/attack.rb', line 5 def critical_dmg @critical_dmg end |
#critical_range ⇒ Object
Returns the value of attribute critical_range.
5 6 7 |
# File 'lib/pfrpg_core/attack.rb', line 5 def critical_range @critical_range end |
#damage ⇒ Object
Returns the value of attribute damage.
5 6 7 |
# File 'lib/pfrpg_core/attack.rb', line 5 def damage @damage end |
#filter_str ⇒ Object
Returns the value of attribute filter_str.
5 6 7 |
# File 'lib/pfrpg_core/attack.rb', line 5 def filter_str @filter_str end |
#macros ⇒ Object
Returns the value of attribute macros.
5 6 7 |
# File 'lib/pfrpg_core/attack.rb', line 5 def macros @macros end |
#other_bonus ⇒ Object
Returns the value of attribute other_bonus.
5 6 7 |
# File 'lib/pfrpg_core/attack.rb', line 5 def other_bonus @other_bonus end |
#range ⇒ Object
Returns the value of attribute range.
5 6 7 |
# File 'lib/pfrpg_core/attack.rb', line 5 def range @range end |
#size ⇒ Object
Returns the value of attribute size.
5 6 7 |
# File 'lib/pfrpg_core/attack.rb', line 5 def size @size end |
#strength_bonus ⇒ Object
Returns the value of attribute strength_bonus.
5 6 7 |
# File 'lib/pfrpg_core/attack.rb', line 5 def strength_bonus @strength_bonus end |
#weapon ⇒ Object
Returns the value of attribute weapon.
5 6 7 |
# File 'lib/pfrpg_core/attack.rb', line 5 def weapon @weapon end |
#weapon_bonus ⇒ Object
Returns the value of attribute weapon_bonus.
5 6 7 |
# File 'lib/pfrpg_core/attack.rb', line 5 def weapon_bonus @weapon_bonus end |
#weapon_name ⇒ Object
Returns the value of attribute weapon_name.
5 6 7 |
# File 'lib/pfrpg_core/attack.rb', line 5 def weapon_name @weapon_name end |
#weapon_type ⇒ Object
Returns the value of attribute weapon_type.
5 6 7 |
# File 'lib/pfrpg_core/attack.rb', line 5 def weapon_type @weapon_type end |
#weight_class ⇒ Object
Returns the value of attribute weight_class.
5 6 7 |
# File 'lib/pfrpg_core/attack.rb', line 5 def weight_class @weight_class end |
Instance Method Details
#as_json(options = {}) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/pfrpg_core/attack.rb', line 44 def as_json(={}) { :weapon_name => @weapon_name, :range => @range, :weight_class => @weight_class, :damage => get_damage.to_s, :weapon_type => @weapon_type, :critical_range => @critical_range, :critical_dmg => @critical_dmg, :weapon_bonus => @weapon_bonus, :strength_bonus => @strength_bonus, :other_bonus => @other_bonus, :attack_bonus => attack_bonus, :filters => filter_str, :macros => @macros.map { |m| m.as_json } } end |
#attack_bonus ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/pfrpg_core/attack.rb', line 30 def attack_bonus attacks = [] static_bonus = NullObject.maybe(weapon_bonus) + NullObject.maybe(other_bonus) + NullObject.maybe(strength_bonus) base = NullObject.maybe(bab) attacks << (static_bonus + base) while(base >= 6) base -= 5 attacks << (static_bonus + base) end return attacks end |
#get_damage ⇒ Object
62 63 64 |
# File 'lib/pfrpg_core/attack.rb', line 62 def get_damage size == 'MEDIUM' ? damage.dmg_m : damage.dmg_s end |