Module: Natural20::SpellAttackHelper
- Includes:
- AttackHelper, Cover
- Included in:
- Firebolt
- Defined in:
- lib/natural_20/concerns/spell_attack_helper.rb
Instance Method Summary collapse
Methods included from AttackHelper
#after_attack_roll_hook, #calculate_cover_ac, #effective_ac
Methods included from Cover
Instance Method Details
#evaluate_spell_attack(battle, entity, target, spell_properties) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/natural_20/concerns/spell_attack_helper.rb', line 5 def evaluate_spell_attack(battle, entity, target, spell_properties) # DnD 5e advantage/disadvantage checks advantage_mod, adv_info = target_advantage_condition(battle, entity, target, spell_properties) attack_roll = entity.ranged_spell_attack!(battle, spell_properties[:name], advantage: advantage_mod.positive?, disadvantage: advantage_mod.negative?) target_ac, _cover_ac = effective_ac( battle, target ) force_miss = after_attack_roll_hook(battle, target, source, attack_roll, target_ac, spell: spell_properties) if !force_miss cover_ac_adjustments = 0 hit = if attack_roll.nat_20? true elsif attack_roll.nat_1? false else target_ac, cover_ac_adjustments = effective_ac(battle, target) attack_roll.result >= target_ac end else hit = false end [hit, attack_roll, advantage_mod, cover_ac_adjustments] end |