Class: Natural20::MagicMissile
- Includes:
- AttackHelper, Cover, Weapons
- Defined in:
- lib/natural_20/spell_library/magic_missile.rb
Instance Attribute Summary
Attributes inherited from Spell
Instance Method Summary collapse
Methods included from AttackHelper
#after_attack_roll_hook, #calculate_cover_ac, #effective_ac
Methods included from Weapons
#compute_advantages_and_disadvantages, #damage_modifier, #target_advantage_condition
Methods included from Cover
Methods inherited from Spell
apply!, #id, #initialize, #label, #validate!
Constructor Details
This class inherits a constructor from Natural20::Spell
Instance Method Details
#build_map(action) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/natural_20/spell_library/magic_missile.rb', line 6 def build_map(action) cast_level = action.at_level || 1 darts = 3 + (cast_level - 1) OpenStruct.new({ param: [ { type: :select_target, num: darts, range: @properties[:range], target_types: i[enemies] } ], next: lambda { |target| action.target = target OpenStruct.new({ param: nil, next: lambda { action } }) } }) end |
#resolve(entity, battle, spell_action) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/natural_20/spell_library/magic_missile.rb', line 34 def resolve(entity, battle, spell_action) targets = spell_action.target targets.map do |target| after_attack_roll_hook(battle, target, entity, nil, nil, spell: @properties) if target.has_spell_effect?(:shield) { source: entity, target: target, attack_name: t('spell.magic_missile'), damage_type: @properties[:damage_type], type: :spell_miss, spell: @properties } else damage_roll = Natural20::DieRoll.roll('1d4+1', battle: battle, entity: entity, description: t('dice_roll.spells.magic_missile')) { source: entity, target: target, attack_name: t('spell.magic_missile'), damage_type: @properties[:damage_type], damage_roll: damage_roll, damage: damage_roll, type: :spell_damage, spell: @properties } end end end |